Reputation
4,336
Top tag
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
13 37
Newest
 Nice Answer
Impact
~942k people reached

Mar
20
comment Looping through files with spaces in the names?
Quoting is a form of masking, isn't it? I don't understand your remark about what is portable, and what not. Your example (2nd from bottom) uses -exec to invoke sh and uses {} - so where is my example (beside -okdir) less portable? find . -name "*.csv" -exec diff {} /some/other/path/{} ";" -print
Mar
19
comment Looping through files with spaces in the names?
instead of find -exec sh -c 'cmd 1; cmd 2' ";", you should use find -exec cmd 1 {} ";" -exec cmd 2 {} ";", because the shell needs to mask the parameters, but find doesn't. In the special case here, echo "$0" doesn't need to be a part of the script, just append -print after the ';'. You didn't include a question to proceed, but even that can be done by find, as shown below in my soulution. ;)
Mar
19
comment Looping through files with spaces in the names?
You don't need IFS, -print0, while and read if you handle find to its full, as shown below in my solution.
Mar
19
comment get numeric ASCII value for a character
This works in bash. You may need i=$((i+1)) instead.
Mar
19
answered Script to list only files of type ASCII text in the current directory?
Mar
19
answered Lightweight X11 alternative available?
Mar
18
comment Looping through files with spaces in the names?
Find already iterates over a subset of files. Most people who show up with questions could just use one of the actions (-ok(dir) -exec(dir), -delete) in combination wiht ";" or + (later for parallel invocation). The main reason to do so, is, that you don't have to fiddle around with file parameters, masking them for the shell. Not that important: You needn't new processes all the time, less memory, more speed. shorter program.
Mar
18
answered Is there a web based converter between rwx and the octal version?
Mar
18
answered Looping through files with spaces in the names?
Mar
18
revised How do I reuse the last output from the command line?
added 92 characters in body
Mar
18
answered How do I reuse the last output from the command line?
Mar
18
answered get numeric ASCII value for a character
Mar
14
answered Find a file in the path without “which”?
Mar
12
comment Deleting all files in a folder except files X, Y, and Z
You're right, I'm sorry.
Mar
12
awarded  Critic
Mar
12
comment Deleting all files in a folder except files X, Y, and Z
a) You move your file X one directory up, where a file X exists - silently deleted, gone. b) You're in the top dir, where no 'up' exists. c) You're in your home, and don't have permission to write to /home. If you put your advice into a script, and tested it without problem, and use it in such a situation - peng!
Mar
12
comment Deleting all files in a folder except files X, Y, and Z
If you have three files a, b and a b the first program will delete - if you put ab into the grep part: "^[ab]$" a and b but not a b, just opposed to your intentions. The second command will do the same. And the third too. You shouldn't use 'ls' in scripts, with very, very rare exceptions. Just don't do it.
Mar
12
comment Deleting all files in a folder except files X, Y, and Z
Since folders under Unix are files (anything is a file), that's maybe what is intended. The question explicitly says: "I have a lot of files and folders in a specific folder and I want to delete all of them; " - and if you like to exclude Y, maybe you know whether Y is a directory or not.
Mar
11
comment Compare files that are in directory 1 but not directory 2?
Yes, it isn't d2/f but d2/f . Tabs and newlines in filenames are rare, but allowed.
Mar
11
revised Compare files that are in directory 1 but not directory 2?
working in all aspects now