Bash commond line

Bash is the major factor lure to unix, then evolve to linux. Traveled a long way from redhat to fedora 13. It is a happy journey. I use bash command daily for various tasks, file management, data manipulation and sever admin etc.

Here is a list of commands, not in a specific order

  • sort, use it in combination with other command output, awk ‘{print $1, $2}’ a.txt | sort
  • uniq use this with sort, for example, awk ‘{print $1}’ a.txt | sort | uniq -c
  • paste
  • wc
  • ls -lat
  • ps -ef

find is my favourable tool,

  • find ./ -name “Makefile*” | xargs gedit
  • find . -mtime 0   # find files modified between now and 1 day ago (i.e., within the past 24 hours)
  • find . -mtime -1  # find files modified less than 1 day ago (i.e., within the past 24 hours, as before)
  • find . -mtime 1   # find files modified between 24 and 48 hours ago
  • find . -mtime +1  # find files modified more than 48 hours ago
  • find . -mmin +5 -mmin -10 # find files modified between 6 and 9 minutes ago
  • find ./PROJECTS/ -size +100M | xargs ls -lath # find files greater than 100 MB

Of cource, at modem linux, the easist way to find a thing is

locate -i myfile

 

Strip DOS ctrl-M’s:

  • :%s/{ctrl-V}{ctrl-M}//

Note: In order to enter a control character, one muust first enter ctrl-v. This is true throughout vi. For example, if searching for a control character (i.e. ctrl-m): /ctrl-v ctrl-M If generating a macro and you need to enter esc without exiting the vi command line the esc must be prefixed with a ctrl-v: ctrl-v esc.

Leave a comment