wiki:Wisdom/Shell

Version 13 (modified by jps@…, 14 years ago) ( diff )

--

Bash Shell Programming

Linux Shell Scripting Tutorial: A Beginner's handbook

You can do a lot of shell scripting type things in python with the os module: http://docs.python.org/library/os.html

To set the modified date to today for everything in a directory and all its subdirectories do

$ find . -exec touch {} \;

To get a list of all files in a directory (one per line) with their paths do

$ find . -type f -print

To remove files that have the string "foo" in them that are distributed throughout various subdirectories do:

$ find . -name '*foo*' | xargs rm

To use the output of one command as the input of another use ` which is the accent key on the upper left corner of the keyboard. For example, let's say you have a text file named listoffits.lis that contains the names of a number of fits files, one per line, you'd like to display on ds9. To display all the files at once in multiple frames in ds9 this do:

$ds9 `more listoffits.lis`

I always forget how to do this:

To tar and compress an entire directory do:

$ tar -zcvf foobar.tar.gz /home/foobar

where /home/foobar is the directory you want to archive.

To untar and uncompress said directory do:

$ tar -zxvf foobar.tar.gz

The v is optional.

Note: See TracWiki for help on using the wiki.