Some shellscripting and find

to copy data you modified in the last 7 days to another directory. you can use:

# copy -r `find /dir/to/my/data/* -maxdepth 0 -mtime -7 -print0` -v -t .

copy -r -> recursive, copy data of data inside of folders
copy -v -> verbose, writes on standard output the files which it is copying
copy -t -> destination folder

find -maxdepth -> how deep find shall look (another option would be -prune)
find -mtime -n -> data which had write access in the last n*24 hours
find -print0 -> write the data without a newline

the shell will first compute the command between the backticks ` and then run the rest of the command, so you do not have to write all the folders for yourself.

this can save some time typing.

with an ampersand (&) you can put any process into the background. with jobs you can see a list of jobs which are currently running in the background. bg and fg put processes in the background or foreground. generally you can stop a process with ctrl + z and put it with bg in the background, it will continue there. then with jobs you can see the number of it and get it with fg %n (n is the number of the process) back to the foreground). so if you want to kill a process in the background, you can use kill %n. in that way you can e.g. start a few rsync processes with just one terminal and overview their status with a few commands.



~ by frankooh on 2011-04-24T12:10:49+00:00.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: