All Questions
56
questions
0
votes
1
answer
57
views
value of $VAR already contains backtick and/or single quote inside. How to handle it? How to properly pass $VAR to program? [duplicate]
$ bash --version
GNU bash, versione 5.2.26(1)-release (x86_64-pc-linux-gnu)
I don't know how to deal with $VAR when its value inside contains single quote (') and/or backtick (`).
I'm in the need of ...
2
votes
1
answer
99
views
Does + need to be escaped in find commands?
I have the following code in bash and I wonder on whether I can get rid of \+ and simply use +
find "$fdir" \
-type f -name "*.org" -o -name ...
1
vote
3
answers
2k
views
find: missing argument to `-exec' in Cygwin
I am trying to get HTML files from component folder and building new component folder and trying to insert that component (New) folder in build folder for Which I am using the given code:
find ...
63
votes
5
answers
42k
views
How to quote arguments with xargs
Suppose that I want to delete all files in a folder that are greater than 1 MB.
$ find . -size +1M | xargs -0 rm
This will not delete files that have space in their names. So I want it to quote all ...
5
votes
3
answers
1k
views
How to recursively set directory permissions with a find that lacks -exec?
My Qnap NAS is cursed with a find command that lacks the -exec parameter, so I have to pipe to something. The shell is: GNU bash, version 3.2.57(2)-release-(arm-unknown-linux-gnueabihf)
I'm trying to ...
1
vote
0
answers
101
views
How to move all the files with specific prefix of the directory? [duplicate]
I have a following directory structure (assume no two files have the same name):
Apple1
apple1.jpg
apple2.jpg
Apple2
apple3.jpg
apple4.jpg
Apple3
Tomato
Peach
And i would like to move one ...
0
votes
1
answer
319
views
How to search for a file by name pattern and execute a command in its directory?
What the following command should do, is to search for all invoice pdf files and check if there is a thumbnail file inside the same directory. If not, it should print the directory. Later I will add a ...
1
vote
1
answer
2k
views
The differences between sed #, %, / and |
I'm trying to replace a string in database. I found the possible solutions below. Using # or % works to me, but not for / and |. Can anyone explain why the first two works and what the differences are ...
2
votes
3
answers
4k
views
-perm flag in find
I'm trying to wrap my head around this command:
find /home/ -type d \( -perm -0002 -a ! -perm -1000 \) 2>/dev/null
I understand that it's going to look in the 'home' directory for all directories ...
5
votes
1
answer
580
views
find usage - command line vs script
I am seeing different results from the find command between being run manually on the command line vs run in a script.
If I run the following on the command line:
find . -name '*.txt' ! -name '*...
10
votes
5
answers
5k
views
find not recursive when given a pattern on the command line
Imagine a source tree. There are xml files everywhere.
But since there is a XYZ.xml at the root of this tree it won't find my xml files.
find -iname *.xml
returns
./XYZ.xml
instead of
./XYZ.xml
....
2
votes
1
answer
231
views
Single quote problem in "sh -c" script launched from "find"
Now I am writing a script for a long time, but lately this problem has drives me crazy. I tried everything but couldn't solve it.
find . -iname "*.mp4" -type f -exec ffmpeg -i "{}" -c:a "$ACODEC" -c:...
39
votes
3
answers
5k
views
GNU find and masking the {} for some shells - which?
The man page for GNU find states:
-exec command ;
[...] The string `{}' is replaced by the current
file name being processed everywhere it occurs in the
arguments to the command, ...
0
votes
1
answer
87
views
Find: Substitute expression with a variable
$ find -name "Bik*"
./Biking
./Biking/Unsync/Biking.md.~6~
./Biking/Rendered/Biking.gen.html
./Biking/Biking.md
Now when I substitute expression with a variable as follows:
$ a='-name "Bik*"'
$ ...
0
votes
2
answers
67
views
Why doesn't $() expand properly?
I want to play all the .mp3 files within a directory using vlc, so I do something like this:
vlc $(find ~/Documents/music -name "*.mp3" -exec "echo \"{}\"" \;)
The issue is that I get "vlc: unknown ...