Reputation
107,559
Next tag badge:
1000/1000 score
200/200 answers
Badges
17 131 270
Impact
~3.8m people reached

Nov
7
comment How can I edit symlinks?
That assumes linkname is not a symlink to a directory. Use the -T option to mv if on GNU or -h if on FreeBSD to avoid that. Note that like ln -sf that does not preserve the permissions of the link (on systems where they are significant).
Nov
7
revised Can a symlink be edited to link to a different directory or file?
added 14 characters in body
Nov
7
revised Can a symlink be edited to link to a different directory or file?
added 37 characters in body
Nov
7
comment How can I edit symlinks?
Note that it assumes test's target is not a directory. Otherwise ln -s -f .profile test would create a .profile symlink in that directory. GNU ln has a -T option to avoid that.
Nov
7
comment How can I edit symlinks?
mv -f (like ln -sf) will not do what you want if $link points to a directory. GNU ln and mv have a -T for that. mv (rename system call) will always change the inode of $link while ln -sfT (unlink+symlink) might reuse the same.
Nov
7
comment Why is printf better than echo?
printf is built in most shells nowadays (bash, dash, ksh, zsh, yash, some pdksh derivatives... so includes the shells typically found on cygwin as well). The only notable exceptions are some pdksh derivatives.
Nov
7
revised Pre-process 1 single option
added 43 characters in body
Nov
7
revised How to know where a program is stuck in linux?
simpler form for gdb
Nov
7
answered Pre-process 1 single option
Nov
7
comment Club together N consecutive line in shell?
I'd give up on xargs. You'd need something like (export LC_ALL=C; sed 's/['\''"\]/\\&/g' < "$file" | xargs -n3 printf '%s:%s:%s\n') which could still be a problem for long lines or inputs with number of lines not multiple of 3, and would also run many processes.
Nov
7
awarded  Nice Answer
Nov
7
comment Club together N consecutive line in shell?
@fedorqui. True, at the cost of legibility though. I also generally avoid using assignments as conditions, because then you need to be extra careful that the assigned value never resolves to false (see KasiyA's answer for instance ($1=$1) for a case where that's a problem).
Nov
7
comment Club together N consecutive line in shell?
-L 3 doesn't pass 3 lines as arguments to the command, it passes the words (words being blank separated, possibly quoted) found in those 3 lines as arguments to the command. The $1=$1 condition will return false if $1 resolves to 0. Try the example I suggested.
Nov
6
comment Club together N consecutive line in shell?
xargs's -L doesn't do what you think it does. It won't work if the input contains blanks or quotes, or some of the fields resolve to 0. See for instance on the output of printf '%s\n' 0 a b 1 '2 3' 4 '5\' 6. Also note that it would run an echo process for every 3 args.
Nov
6
revised Club together N consecutive line in shell?
POSIX sed implementations will discard the pattern space if N is called on the last line
Nov
6
comment Club together N consecutive line in shell?
@Jidder, if awk < file is processed differently from awk file, then that'd be a bug in the particular awk implementation, or we're talking non-POSIX systems. While the awk ... file==x is a problem with any awk implementation (can be worked around with awk ... ./file==x though).
Nov
6
revised Club together N consecutive line in shell?
deleted 14 characters in body
Nov
6
comment Club together N consecutive line in shell?
@Jidder, it's rather the other way round (file name passed to awk) that's a problem (like for files with = in their name).
Nov
6
revised How to recompress 2 million gzip files without storing them twice?
added 9 characters in body
Nov
6
reviewed Approve How to recompress 2 million gzip files without storing them twice?