Tags: unix, os x, linux, command line, terminal, bash, shell
Date: 2013-08-20 23:09:02
To learn more, try the command line basics and UNIX tutorials found at http://www.ee.surrey.ac.uk/Teaching/Unix/ and http://www.westwind.com/reference/OS-X/commandline/navigation.html.
Open a command line shell:
- use 'Terminal' on OS X or Linux
- use cygwin on Windows (need to install first)
List files
ls
Change directory
cd Desktop
Change up one directory level
cd ..
Print current directory location
pwd
Go to root of drive
cd /
Go back to user home folder
cd ~
Read in the Lord Of The Rings (LOTR) calendar with concatenate (should work on most Linux and Mac OS X systems):
cat /usr/share/calendar/calendar.lotr
Read help for cat
man cat
Use b
and spacebar
to move forward and backwards a page at time when viewing man help pages. Press q
to quit.
Find all lines about 'Frodo' by piping the output from 'cat' into the 'grep' find program with the pipe operator |
:
cat /usr/share/calendar/calendar.lotr | grep 'Frodo'
Same exact result as giving grep both original inputs:
grep 'Frodo' /usr/share/calendar/calendar.lotr
Find all lines ending with 'Gandalf' using a 'regular expression' search pattern. To do this use the flag -e
and the $
in the search pattern to indicate the line ending position:
cat /usr/share/calendar/calendar.lotr | grep -e 'Gandalf$'
Save this output to a file on the Desktop. Notice the usage of both a pipe |
and a redirection of output >
:
cd ~/Desktop
cat /usr/share/calendar/calendar.lotr | grep -e 'Gandalf$' > testfile.txt
Append something to the file using the redirection with append marker >>
:
echo 'Double Rainbow!' >> testfile.txt
List usage in human-readable format for a directory
du -sh *
ls -lT *.tif | sort | awk '{ print $10, $8 }' > frametimes.txt
find . -name '*.tif ' | xargs ls -lT | sort | awk '{ print $10, $8 }' | sed -Ee 's/^.\///g' > ~/Desktop/frametimes.txt
ls -lTU *.tif | awk '{ print $6, $7, $8, $9}' > ~/Desktop/frametimes.txt #U is file creation date-- file modification time might be better...
ls -lT *.tif | awk '{ print $6, $7, $8, $9}' | pbcopy
ls -lT *.tif | awk '{ print $10}' > ~/Desktop/frametimes.txt
ls -lT *.tif | awk '{ print $10}' | pbcopy
ls -lTU *.tif | awk '{ print $6, $7, $8, $9 }' > ~/Desktop/movietimes.txt
tiffutil -info filename.tif
rsync -av --max-size=500M FilePathToSource FilePathToDestination