2010/09/28

Favorite command line tricks in Linux

The following are a list of commands that have been useful for me on the linux command line. Please use the 'man' command from the terminal to learn how to use the commands.

'>>' text that follows these symbols are to be entered on the command line.

>>man  [command] # prints manual/instructions and options for the linux command. Type 'ctrl' + 'z' to exit the manual. Example >>man find #shows instructions for find command
>>rm [filename]# deletes file
>>cp [filename] [destination]#copies file to destination
>> find #finds files, a very powerful command because its list of files can be piped '|' into another command which allows processing a large number of files at once.
>>xargs [options] command # build and execute command lines from standard input (which is normally the keyboard).

  • -0 #Useful when input items  might  contain  white  space, quote marks, or backslashes.
  • -I #Replace occurrences of replace-str in the initial-arguments with names read from standard  input. Also, unquoted blanks do not terminate input items; instead the separator is the newline charac‐ ter.  Implies -x and -L 1.
  • --max-procs=max-procs # Run up to max-procs processes at a time; the default is 1.  If max-procs is 0, xargs will run  as
    many processes as possible at a time.  Use the -n option with -P; otherwise chances are that only one exec will be done.
    xargs -0 -I "{}" ~/Documents/py/speedup.py "{}"
find -name "*.mp3" -print0 | xargs -0 --max-procs 2 -I "{}" [command] "{}"

Tags: command line, shell, linux, find, arg, man

No comments:

Post a Comment