104,674 reputation
13123255
bio website
location European Union
age
visits member for 2 years, 7 months
seen 8 hours ago

Jan
30
answered Capture in shell variables the arguments after a command (between brackets)
Jan
30
revised process substitution for opening a list of files with an application
It's IFS= to avoid problems with trailing blanks. -print0 is only for newline character. -d $'\0' is misleading in anything but zsh since other shells don't support it (and expand to the empty string or worse). -name '*' doesn't do anything (matches all files).
Jan
30
comment How create a temporary file in shell script?
mktemp originated in HP/UX with a different syntax. Todd C. Miller created a different one for OpenBSD in the mid-90s (copied by FreeBSD and NetBSD) and later made it also available as a standalone utility (www.mktemp.org). That's the one that was typically used on Linux until a (mostly compatible) mktemp utility was added to the GNU coreutils in 2007. Just to say one cannot really say mktemp is a GNU utility.
Jan
30
comment How create a temporary file in shell script?
@WinnieNicklaus, yes, but that doesn't use temporary files so is irrelevant here. Process substitution was introduced by ksh, copied by bash and zsh, and zsh extended it with a 3rd form: =(...).
Jan
30
comment What are the root permissions for a file?
root doesn't have execution permission unless at least one of the execution bits is set.
Jan
30
comment Remove all files recursively without deleting directories
-exec rm {} + is not parallel, it just calls rm with several file names. It runs fewer rm invocations so is more resource-friendly. If it slightly less safe in that it enlarges the race window within which a directory component of the files to remove may be changed to a symlink. But only -delete or -execdir rm {} \; would fully address that.
Jan
30
comment Remove all files recursively without deleting directories
@Costas, I strongly doubt that legend given that even the 2BSD (1978, where csh was first released) csh man page clearly documents {} is passed undisturbed.
Jan
30
comment Remove all files recursively without deleting directories
@Costas, -type f only includes regular files (not symlinks, sockets, fifos, devices, doors...).
Jan
30
comment Remove all files recursively without deleting directories
@ScottWilton, -delete is GNU (and some BSDs) only, -exec rm is standard (though less safe)
Jan
30
comment Remove all files recursively without deleting directories
@Costas, no, there's no shell that requires escaping + (at least not in the Bourne, csh or rc families). There's a legend that says that some old versions of csh required escaping {} but I've never come across those.
Jan
30
comment Remove all files recursively without deleting directories
What about symlinks to directories?
Jan
30
revised Remove all files recursively without deleting directories
`-type f` is for regular files only.
Jan
30
comment Remove all files recursively without deleting directories
Do you want to delete files (hidden or not) in hidden directories?
Jan
30
revised Find the line number which contains the pattern with custom delimiter
added 52 characters in body
Jan
30
comment Find the line number which contains the pattern with custom delimiter
sed -n '\|file /etc|='
Jan
30
revised read first element in array
POSIXified. (woulnd't work in OS/X otherwise)
Jan
30
revised Change of voice via ffmpeg or other application
added 33 characters in body
Jan
30
revised List the files of another format while finding a certain name pattern
clarify
Jan
30
revised Bash escaping is confusing me
added 13 characters in body
Jan
30
revised ss is replacing netstat, how can I get it to list ports similarly to what I am used to?
typo.