| bio | website | zealot-trivia.net |
|---|---|---|
| location | United States | |
| age | 32 | |
| visits | member for | 2 years, 8 months |
| seen | Apr 9 at 13:05 | |
| stats | profile views | 19 |
Just another Perl hacker.
Just say NO to ls! It's a gateway drug and can lead to all kinds of sloppiness.
|
Sep 27 |
awarded | Yearling |
|
Jun 25 |
comment |
What is the difference between : and true? The behavior of : as a label indicator for goto was preserved in Microsoft's pseudo-Unix command line clone, command.com, and remains in its successor cmd.exe, as does the practice of abusing :: for a line comment. |
|
Jun 8 |
revised |
Strip spaces after single capital letters with sed added sed version |
|
Jun 8 |
answered | Strip spaces after single capital letters with sed |
|
Apr 5 |
comment |
Shell script for moving oldest files? @l0b0: My proposed solution is while IFS= read -r -d '' line ; do file="${line#*.*.}" ; echo "$file" ; done < <(find test -printf '%T@.%p\0' | sort -z -n -t. -k1,2) - sort on the first two numeric . delimited fields, then strip the first two such fields to obtain the filename. What do you think? Related question: Do you have test data for the -n failure with floats? |
|
Apr 5 |
comment |
Shell script for moving oldest files? @l0b0: I see what you mean, the second-part is not zero padded (only the fractional part is), but for %TS it works correctly. How annoying! I still don't like your original solution (seems kind of messy). |
|
Apr 5 |
comment |
Shell script for moving oldest files? @MichaelMrozek: It is a bad idea and it's bad because it fails sometimes. If you have the option of doing what fails sometimes and what doesn't, you should take the option that doesn't (and the one that does is bad). Do whatever you like interactively, but in a script file and when giving advice do it correctly. |
|
Apr 5 |
comment |
Shell script for moving oldest files? @MichaelMrozek: Seriously. If it's a bad idea, how about not doing it? |
|
Apr 5 |
comment |
Shell script for moving oldest files? @l0b0: A string sort on %T@ would also work, then, because it is zero-padded. |
|
Apr 5 |
comment |
Bash, remove oldest files If I may mercilessly steal an idea from @Peter.O, try ((++counter>3)) as your test. It's nicely succinct. As for oneliners: If brevity is a concern wrap the code in a function, then don't worry about it. |
|
Apr 5 |
comment |
Shell script for moving oldest files? @l0b0: Your solution exhibits the same bug, regardless: %TS also shows a "fractional part" which would be in the form 00.0000000000, so you also lose granularity. Recent GNU sort could solve this problem by using -V for a "version sort", which will handle this type of floating point as expected. |
|
Apr 5 |
comment |
Why escape trivial characters in shell script? Although there is a good reason for it, providing alias protection in a script using this method is not what I'd call "recommended." It would be sufficient to clear the alias at the top of the script, or to invoke rm by full path. |
|
Apr 5 |
comment |
Shell script for moving oldest files? @l0b0: This limitation is known to me. I presume that it is sufficient to not require that level of granularity (that is, sorting beyond the . must be irrelevant to you.) It would be clearer to say sort -z -n -t. -k1. |
|
Jan 16 |
comment |
Shell script for moving oldest files? -1, dangerous. Here let me craft an example: touch $'foo\n*'. What happens if you execute mv "$(ls)" with that file sitting there? |
|
Jan 16 |
comment |
Shell script for moving oldest files? +1, only useful answer prior to mine (and it's always good to have test data.) |
|
Jan 16 |
answered | Shell script for moving oldest files? |
|
Jan 12 |
comment |
How to delete the oldest directory in a given directory? @AAaa: You're running into quote-and-escape issues. You need to make sure that the remote shell is the one that expands the variables, not the local one. |
|
Jan 12 |
revised |
How to delete the oldest directory in a given directory? added complete sample |
|
Jan 12 |
comment |
How to delete the oldest directory in a given directory? @AAaa: If you replace the . with an (absolute) path it should work. If it were me I'd replace . with "$dir" and set dir to whatever I needed ahead of time. Otherwise, yes, you would need to cd first. |
|
Jan 12 |
comment |
Is using cookies from a web-browser a sane rationale for desktop application development? The most popular are certainly Firefox or a clone, Mozilla Suite/Seamonkey, Chrome or Chromium, Konqueror, Epiphany and Opera. Note that this list is not in order. |