Reputation
549
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
2 9
Impact
~29k people reached

  • 0 posts edited
  • 1 helpful flag
  • 71 votes cast
May
3
comment How can I rename a file whose name is in itself a full path (e.g. begins with “g:\”)?
There's actually nothing invalid about this file name as far as NTFS is concerned, it's merely a limitation of Windows that prevents it from being properly referenced.
Mar
17
comment apt-get “Broken packages”
It would be helpful if you posted your complete sources.list (including anything from sources.list.d/), and also your apt-preference (/etc/apt/preferences*) and the output of dpkg -l '*' | grep ^h (if any).
May
22
comment Test if a package is installed in APT
While this is doubtless correct I find that dpkg-query -l "$package" | grep -q ^.i is usually sufficient (and easier to remember).
Dec
15
comment logout without being at login shell
Just kill the login shell. Identifying the PID is the only issue.
Dec
6
comment How to check if a directory exists in Windows?
@grawity: If it exists but is a file the script will probably fail later when trying to use it as a directory, which probably isn't what you want.
Nov
4
comment Mass Rename Files with bash
In fact, I'd be much better with find -> generate shell code. The reason for this is that find is less likely to mangle filenames than ls. In the real world I'd just use mmv for this, or a while read command substitution loop pulling nul-terminated filenames from find. Or, if the files are nicely globbable, a simple for loop as glenn used in his answer.
Nov
4
comment How to use Grep in Unix command line?
It depends on how you define a word boundry, of course.
Nov
4
comment Mass Rename Files with bash
ls piped to sed piped to sh? My brain is melting.
Oct
14
comment Is there any GUI tool to configure /etc/fstab?
The old kfstab was a good tool for this, but it's sadly bitrotten by now. There're fwfstab and gfstab as well, but they don't seem maintained. In the future I expect the excellent palimpsest will evolve the ability to actually edit fstab, then all will be well.
Oct
14
comment What is naming convention for subtitle files?
What if there's more than one file for the same language? E.g., multiple translations.
Sep
6
comment Why is 'grep -i' so slow? How to do it faster for ASCII?
Case insensitivity is hard, especially if you're doing it on unicode input.
Jan
26
comment List/remove files, with filenames containing string that's “more than a month ago”?
As it turns out you can use -newerXY where Y is t to specify a timestamp directly (for GNU find it's GNU date -d format) to avoid the need to create an intermediate file. This will be a little faster, as Rich mentions.
Jan
25
comment How to search for a pattern between lines 1500 to 2500?
I worry about the possibility of false positives in the grep match if I do that. Probably it should be an additional switch. What "line number" means when there are multiple files is also a question.
Jan
25
comment How to search for a pattern between lines 1500 to 2500?
You're all quite right, but just for fun I added an answer using torso. I sidestepped the line number question by pretending that it doesn't exist.
Jan
25
comment How to search for a pattern between lines 1500 to 2500?
Though it's more efficient to write this as one script I can't help but thinking that this is a missing tool. As a complement to head and tail, a tool that gives you a specific range of lines or bytes out of the middle of a stream (based on offset from the start). We could call it torso or thorax.
Jan
25
comment find -exec command works on Debian Squeeze but not Ubuntu 10.04
Is the ~/bin/ mentioned exactly the same in both cases? Not just the same file list and contents, but the same underlying device/filesystem?
Jan
20
comment “tar -xzf” for many “tar.gz” files in a directory
I did not omit the z in my example for this reason. There's another reason not to use a leading switch which feeds in to the reason you might omit the z: One less character to type.
Jan
18
comment “tar -xzf” for many “tar.gz” files in a directory
Other for loops on this page break on spaces and special characters, so I did not vote them up. Their form was correct with simply a small omission. This one breaks that way, too, but does it in a more egregious manner. The output of ls is for human consumption only unless you use -1 or similar, but even then I would avoid it. See ParsingLS.
Jan
18
comment what exactly happens when I “sudo apt-get install php-pear”
I will just mote that as a rule of thumb "If you can install it via a package manager, you should install it via a package manager." You may not see the advantage today but sooner or later you'll appreciate it. That said, only do it if the version available is suitable to your needs. I, personally, install nothing that cannot be installed via APT; everything else is too much work!
Jan
18
comment “tar -xzf” for many “tar.gz” files in a directory
I would want to include -maxdepth 1 to avoid accidental expansion of tarballs in subdirectories.