663 reputation
5
bio website
location
age
visits member for 6 months
seen 30 mins ago
stats profile views 21

May
14
revised How do I specify arguments to return all dot files, but not . and ..?
added 171 characters in body
May
14
answered How do I specify arguments to return all dot files, but not . and ..?
May
13
revised How to kill the (last - 1) PID with bash
added 465 characters in body
May
13
revised How to kill the (last - 1) PID with bash
added 465 characters in body
May
13
answered How to kill the (last - 1) PID with bash
May
10
comment Why is sed giving me an error about an unterminated `s'?
$FOO4 contains something weird (ex: "\" or "\\" ?) that makes the sed s command not terminated. (That's why I think it's a trailing "\", making the next "/" be treated as a character part of the replace string, instead of as the terminating character for the s command)
Apr
30
comment How can I prevent 'grep' from showing up in ps results?
@LarsH : indeed ^^ (I'm tired, read the 2nd part as a regexp ^^). Good catch! (And doing that, it proves my first comments were wrong also on the intent!) Indeed Bravo to xaccrocheur ^^ the idea is, in retrospect, neat (and +1 worth!). It could be rewrote as a generic function : function newps { for i in "$@" ; do ps aux | grep "$(echo $1 | sed 's/^\(.\)/[\1]/g')" ; done ; } #but may need testing ^^. Use: newps exe1 exe2
Apr
30
comment How can I prevent 'grep' from showing up in ps results?
Thanks (+1) for your humor :) And I made a mistake too : you don't ask sed to replace "each char in fnord by its own value" : as you anchor the regexp to the left of the string, you only replace "f" by "f" ... a bit like sed "s/^./&/" would do, but adding the comedic effect of saving it in a named buffer ^^
Apr
30
comment How can I prevent 'grep' from showing up in ps results?
I apologize as the tone of my above comment may sound offensive (and I can't edit it after 5mn)... Your answer was really a joyful read, and I wasn't trying to make you look bad. I really think you did it like this on purpose ^^
Apr
30
comment How can I prevent 'grep' from showing up in ps results?
this looks like an IOCCC, but for unix command line instead of C ^^ Just | grep $(echo fnord) wasn't enough ? you also ask sed to search and replace each char in "fnord" by its own value? ^^ congrats. I bet I can do an even longer one, but it probably won't be as funny ^^
Apr
26
comment difference between function foo() {} and foo() {}
That's a BIG difference, portability... I see too many answers which simply do NOT work on (older) production systems, and also many with options that only work on linux. At least, warn that this is not the most portable way... It could be downright dangerous (asking someone to tar cf - /some/thing | ssh user@desthost "cd destinationdir && tar xf - " without warning them to first double-check if the version of tar on desthost will get rid of the "/" could lead to disasters in some cases...). For ex: if use a function tar { #a safe tar with safety checks ... } and sh ignores it, ...
Apr
22
comment How to move the files based on Year
You can workaround this : use touch to create a /tmp/ANCHORJAN2012 file of date 2012/01/01 0h00 ...... , and same for /tmp/ANCHORJA2013file (Jan 1 2013 0:00). Then: find /path \( -newer ANCHORJAN2012 -a \! -newer ANCHORJAN2013 \) -print
Apr
22
comment How to move the files based on Year
Nice way. To be very "nitpicky" : -mtime -1 : is any file in the last 24hours. Not just the files from yesterday (or today). So, there will also be a little "overlap" : if you determine it's been 120 days since 2012, and today it is 15:45 when you launch the script, you'll end up selecting files up to dec 31 15:45 (and not the last ones of that day)... You can probably use: nb_day - 1, and then "weed out" the few ones who dates from 2013 (those could be found by a ls -l | grep -v, BUT the output differ if they are 1 day old only... lots of pitfalls...)
Apr
22
comment sort ls output by users
@depquid : of course ^^ But they also could just have an alias, or a function, changing the output (ex: adding the inode in front) ^^ (but you can use "command ls" instead of "ls" in bash to bypass both)
Apr
19
comment sort ls output by users
@nylon100: a lot of unixes (and even on the same one, different version of the OS or the ls command) will act differently with many commands. It's good to be extra careful about portability, as a simple script here would be dangerous there (ex: if you rely on column 3 to find which files to delete, and it happens it contains something else than the owner's name, you may end up deleting every files you wanted to keep...)
Apr
19
comment sort ls output by users
@depquid: no problem ^^ it happens (and I tend to edit a lot, as I throw things out before actually trying them...).
Apr
18
comment sort ls output by users
@depquid: I edited to break as soon as a match occurs (but if you need the group, it will get a bit more difficult, where you'll need to take the last (=1st if only 1 number returned, or 2nd if 2 number returned in case user=group))
Apr
18
revised sort ls output by users
added 18 characters in body
Apr
18
comment sort ls output by users
@depquid: I don't understand: my 1) part take care of finding the columns using the myls command. Assign myls=the_command_you'll_actually_use and it will be determining the columns for that actual command (be it alias or anything) and then the sorts will be using those found values.
Apr
18
comment sort ls output by users
the awk are done for clarity, not tersity... I'm sure a guru out there will propose a much neater/shorter way