UNIX Commands: Difference between revisions

From Genecats
Jump to navigationJump to search
(changed "fl nm" to "flnm" and "tbl nm" to "tblnm" because I think it is eaiser to read/understand)
Line 1: Line 1:
==Shorthand Key:==
==Shorthand Key:==
  file name fl nm
  file name flnm
  database name dbnm
  database name dbnm
  table name tbl nm
  table name tblnm


==Common Unix Commands==
==Common Unix Commands==
Line 23: Line 23:
  egrep extended grep
  egrep extended grep
  -v remove this
  -v remove this
  rm fl nm remove file
  rm flnm remove file
  diff flnm1 flnm2 shows differences between two files
  diff flnm1 flnm2 shows differences between two files
  cp fl nm copy file
  cp flnm copy file
  mv fl nm move copy file
  mv flnm move copy file
  mv fl nm new fl nm         rename file from fl nm to new fl nm
  mv flnm new flnm         rename file from flnm to new flnm
  ^ beginning of a line or begins with
  ^ beginning of a line or begins with
  \ escapes a character (insert char. don’t execute its comnd)
  \ escapes a character (insert char. don’t execute its comnd)
Line 33: Line 33:
  df name of machine
  df name of machine
  command | more         give the first few records & give one more line when "enter" is clicked
  command | more         give the first few records & give one more line when "enter" is clicked
  > fl nm put in file
  > flnm         put in file
  J takes next line and prints it to the screen
  J takes next line and prints it to the screen
  :. , $ from here to the end of the line
  :. , $ from here to the end of the line
  ~ toggles between the last two places
  ~ toggles between the last two places
  ssh machine         open shell on that machine (ex  ssh hgwdev)
  ssh machine         open shell on that machine (ex  ssh hgwdev)
  cat fl nm print this file to the screen (rather than vi)
  cat flnm print this file to the screen (rather than vi)
  cat fl nm | grep “criteria” print only the criteria of the file to the screen
  cat flnm | grep “criteria” print only the criteria of the file to the screen
  head fl nm first 10 lines of file in window
  head flnm first 10 lines of file in window
  tail fl nm last 10 lines of file in window
  tail flnm last 10 lines of file in window
  history shows you every command typed in session
  history shows you every command typed in session
  !# displays that line number in command line (ex. !20)
  !# displays that line number in command line (ex. !20)

Revision as of 15:57, 30 March 2011

Shorthand Key:

file name		flnm
database name		dbnm
table name		tblnm

Common Unix Commands

pwd				present working directory
ls				list directories/files
ls –ltr			lists directories/files without a “.” in front
ls –ltra			lists directories/files with a “.” In front
ls -1				lists directories/files with one entry on each line
ls –L				shows just sym link names, not destination
ls –L1 flnm*			shows names & sym links & lists them one/line that start with “flnm”
!$				last argument on previous line (space to end)
hgsql db nm		        gets us in mysql database
Ctrl + c			cancels command in progress
h				history
cp				copy
mkdir				make directory
cd -				back to the last place you were
cd				takes all the way to the top no mater where you are
grep				search/find
egrep				extended grep
-v				remove this
rm flnm			remove file
diff flnm1 flnm2		shows differences between two files
cp flnm			copy file
mv flnm			move copy file
mv flnm new flnm	        rename file from flnm to new flnm
^				beginning of a line or begins with
\				escapes a character (insert char. don’t execute its comnd)
|				pipe to
df				name of machine
command | more		        give the first few records & give one more line when "enter" is clicked
> flnm			        put in file
J				takes next line and prints it to the screen
:. , $				from here to the end of the line
~				toggles between the last two places
ssh machine		        open shell on that machine (ex  ssh hgwdev)
cat flnm			print this file to the screen (rather than vi)
cat flnm | grep “criteria”	print only the criteria of the file to the screen
head flnm			first 10 lines of file in window
tail flnm			last 10 lines of file in window
history			shows you every command typed in session
!#				displays that line number in command line (ex. !20)
sudo mypush db tbl hgwbeta	push a table to hgwbeta (from dev)
diff flnm1 flnm2		difference between two files

cat flnm | awk -F\. '{ print $1 }'	makes deliminator a "." and prints the first column (before the ".")

ls -1 | wc -l 			number of flies in a directory
ps				processes running in terminal, -e for everything, -ef for everything full, | grep katrina for just my stuff
ctrl+z				halts a job
bg				background (must do ctrl+z first)
fg				foreground

samtools view -x <file> <pos> | grep <QNAME> | sed 's/\t/\n/g'		prints bam records in a region with particular QNAME vertically with the FLAG field in hex (made alias: sv = 'samtools view -x')

To view processes: http://www.cyberciti.biz/faq/show-all-running-processes-in-linux/
kill processId		to force quit a command that you can't "ctrl + c" out of (must open another window and view processes first)


Sym Link

  • Make a Sym Link:
ln –s location sym link name

ex.
ln –s kent/src/hg/makeDb/trackDb trackDb
  • Use a Sym Link:
cd ~/sym link name

ex.
cd ~/trackDb