Skip to main content

All Questions

Tagged with
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 ...
dAllARA's user avatar
  • 33
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 ...
Pietru's user avatar
  • 393
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 ...
S. McCandlish's user avatar
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 ...
spiridon_the_sun_rotator's user avatar
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 ...
flowermia's user avatar
  • 141
2 votes
1 answer
228 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:...
user avatar
0 votes
1 answer
86 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*"' $ ...
Porcupine's user avatar
  • 2,056
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 ...
unix's user avatar
  • 3
0 votes
2 answers
909 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 ...
SBTech's user avatar
  • 19
3 votes
1 answer
3k views

find: unknown predicate `-p'

find /log/ -mtime -31 -type f -name ""*data.txt"" -printf ""cp -p %p /Backup/%Td/\n"" | sh I am trying to set up this command in a cron job and it's complaining about unknown predicate -p. Not really ...
GA_train's user avatar
3 votes
1 answer
694 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 ...
joker's user avatar
  • 594
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" "*...
lonix's user avatar
  • 1,783
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), ...
Biomage's user avatar
  • 145
1 vote
1 answer
427 views

variable `-name` primary to `find`

I am trying to construct a compound -name primary for the find command from an arbitrary number of strings in an array, of the form \( -name ${a[0]} -or -name ${a[1]} -or -name ${a[2]} ... \). While ...
user001's user avatar
  • 3,728
0 votes
1 answer
318 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 ...
Aley's user avatar
  • 163

15 30 50 per page