The Archives

  • 03.Jul.12
    Dash dash… shell | fernape | (0)
    There are some situations when someone messes up with his text editor, file browser or shell and ends up creating a file called something like "-test". Selecting the file on the file browser and pressing "Delete" should eliminate it. However, as you will probably have noticed, this blog is called "commandliners" so I am going to explain how to delete this files from a shell. A naïve try would be something like the following: $ rm -fichero which leads to the following error: rm: illegal option -- l usage: rm [-f | -i] [-dIPRrvW] file ... unlink file Here, -file is ...
  • 26.Apr.09
    Command line Russian roulette fun | rafacas | (1)
    $ [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo Click Please notice that this is a fun command before copying and pasting. Via | xeoncross tweet.
  • 10.Feb.09
    Some xargs scripts, shell | pfortuny | (1)
    Rafacas has already mentioned it, but xargs is sometimes much more useful than what it looks like. Two examples come to mind: Way too many files for rm or ls. It may well happen that a script has generated more than 10000 files in the same directory (it was your friend, not you, I know). If you try and rm * in there, you will be in trouble. Ditto if you simply want to count them with ls | wc -l. However, the following works: $ find . -type f -print0 | xargs -0 ls | wc -l (or rm instead of ...
  • 15.Oct.08
    Safe remove cmd | rafacas | (0)
    rm -P file.txt Overwrite regular files before deleting them. Files are overwritten three times, first with byte pattern 0xff, then 0x00, and last with 0xff, before they are deleted.