All Questions
18
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 ...
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 ...
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:...
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 ...
0
votes
2
answers
917
views
Find not working as expected with space in directory
I have a script calling this
find "/mnt/Data/Shared/$1" -type d -exec bash -c 'fixperm "'${1}'" "fd" "$0"' {} \;
$1 is a directory, when the name contains no spaces it works, when there is a space ...
3
votes
1
answer
700
views
Commands Differences Using Quotations (Find)
I was reading the man page of find and I found myself confused with the following commands. What is the difference between one and its corresponding one.
What is the difference between the following ...
3
votes
1
answer
1k
views
Escaping problem with find command
I need to find everything in a directory, excluding certain subdirectories and files. My script needs to call this as a function:
function findStuff() {
# define exclusions
ignore_dirs=("$1" "*...
1
vote
1
answer
2k
views
Using a bash loop to run a program that uses single-quotes in the command line, where single-quotes nullify the bash script's intention
The problem:
I want to be able to run a program within a bash loop over each .fna file in a directory, but I also want the name of the output file to have the same file name (without the extension), ...
2
votes
2
answers
200
views
How to protect expressions in the 'find' command from interpretation by the shell?
I would like to run the command find . '! -name *.*' in the bash shell. It does not work as intended. (It should list all files in the current directory for which -name *.* is false, i.e. which do not ...
1
vote
1
answer
3k
views
find -exec not working in bash script but working in terminal [duplicate]
I am trying to write some bash script to replace a command I quite often use. Here is the code from my file test.sh
#!/bin/bash
echo -e "\n"
i=0
args[i++]=$0
for arg in $@ ; do
args[i++]=$arg
done
...
1
vote
2
answers
3k
views
find "corrupt" file, nesting an if inside a find command
I'm trying to find "corrupt" files inside a directory structure, namely files which the file command would interpret as "data".
Here is the command I've been trying to run, but fails:
$ find . -type ...
21
votes
3
answers
16k
views
How does 'find -exec' pass file names with spaces?
If I have a directory containing some files whose names have spaces, e.g.
$ ls -1 dir1
file 1
file 2
file 3
I can successfully copy all of them to another directory like this:
$ find dir1 -mindepth ...
2
votes
2
answers
7k
views
Using exec in find over ssh from shell script
So, I am attempting to execute the following from within a shell script;
ssh -q $CUR_HOST "cd $LOGS_DIR; echo cd $LOGS_DIR; find . -name *.log -mmin +1440 -exec gzip {} \; exit"
When this runs, it ...
24
votes
5
answers
45k
views
Using a generated list of filenames as argument list -- with spaces
I'm trying to invoke a script with a list of filenames collected by find. Nothing special, just someting like this:
$ myscript `find . -name something.txt`
The problem is that some of the pathnames ...