Reputation
22,648
Next tag badge:
894/400 score
77/80 answers
Badges
3 51 81
Newest
 Enlightened
Impact
~980k people reached

Apr
2
comment Four tasks in parallel… how do I do that?
@DigitalRobot You can try it for yourself but the xargs man page seems to imply it will try to keep 4 processes running at all times.
Apr
2
comment Light GUI user interfaces
Are you looking for a full DE? Many people seem to be suggesting window managers but if you go that route you'll have the burden/freedom of choosing all your DE components like pagers, panels, file managers, etc. yourself.
Apr
1
comment Editing a file without overwrite permission
@Mat is right. This doesn't make any sense. What are you trying to do?
Apr
1
comment Four tasks in parallel… how do I do that?
@EugeneS It's for maximum correctness and robustness. File names are not lines, and ls cannot be used to parse filenames portably and safely. The only safe characters to use to delimit file names are \0 and /, since every other character, including \n, can be part of the file name itself. The printf uses \0 to delimit file names, and the -0 informs xargs of this. The -I{} tells xargs to replace {} with the argument.
Apr
1
comment Four tasks in parallel… how do I do that?
@EugeneS Could you be a bit more specific about what part? The printf collects all png files and passes them via a pipe to xargs, which collects arguments from standard input and combines them into arguments for the pngout command the OP wanted to run. The key option is -P 4, which tells xargs to use up to 4 concurrent commands.
Apr
1
comment Is it possible to reference the most recently modified file in a command line argument?
@user1247 You have to make all your functions look like, e.g. cdtest () { cd "$@"; }, and then they should work with arguments.
Mar
31
comment Home key acting strange in bash (tty and X) on long input strings
@LevLevitsky I added a short explanation to the answer.
Mar
31
comment Four tasks in parallel… how do I do that?
Just to explain my fixes to the code: (1) As a matter of style, avoid all uppercase variable names as they potentially conflict with internal shell variables. (2) Added quoting for $f etc. (3) Use [ for POSIX compatible scripts, but for pure bash [[ is always preferred. In this case, (( is more appropriate for the arithmetic.
Mar
31
comment Is it possible to reference the most recently modified file in a command line argument?
@user1247 type set -x (turn on xtrace) and try again and see what it tells you.
Mar
31
comment Is it possible to reference the most recently modified file in a command line argument?
@user1247 Sorry I got distracted from the bigger picture. The fundamental problem is aliases are expanded when functions are read, not when they are executed. The function expands its arguments to obtain the command to run, so passing in aliases won't work. The solution is simple: change your aliases to functions, which do work, since functions supersede aliases anyways.
Mar
31
comment Is it possible to reference the most recently modified file in a command line argument?
@user1247 I would just copy paste it instead of sourcing it, since you have to tweak it anyways. last_file () { #copy paste code here }. The only change to make is to change the exit to return, so the function doesn't exit your shell.
Mar
29
comment ls taking long time in small directory
Try /bin/ls (or rather, command ls) to run ls without the aliased options, to confirm whether or not it is the color option that is making a difference. FWIW, ls turns off coloring when its output is a pipe or other non-terminal device.
Mar
29
comment ls taking long time in small directory
Run type ls to check any possible aliases etc.
Mar
29
comment Replace whole line in a file from command-line
The -i option to sed is non-standard and usually breaks symlinks. If you have GNU sed you almost always want to add the option to --follow-symlinks. In general, I recommend avoiding sed -i and using ed instead. Files are not streams.
Mar
27
comment How to make `find` output full absolute file names?
I'd advise quoting "$PWD" just in case.
Mar
27
comment How do I add network or user source connection data to history entries?
Sounds like process accounting may be useful. The shell history was never designed for logging, and if you do want to use it you have to trust all of your users. See related question on monitoring activity and a related answer.
Mar
27
comment Why did adding the Debian testing repository create so many package dependencies?
Is the version in backports still too old for your purposes?
Mar
23
comment Trying to set JAVA_HOME in ~/.bashrc
Getting the obvious question out of the way: have you restarted bash / reloaded the rc file since making the change?
Mar
23
comment Is it possible to reference the most recently modified file in a command line argument?
Even though file names ending in newlines are uncommon, it should be noted that command substitution strips trailing newlines, even when quoted.
Mar
23
comment permission reporting on sudoers
Do you mean sudo -l?