GenWikiLinux

From birchyHistory
Jump to: navigation, search
(Create shortcuts in Linux (symbolic links))
 
Line 3: Line 3:
  
 
== GREP ==
 
== GREP ==
grep [options] "foo" [file(s)]
+
grep [OPTIONS] "REGEXP" [FILES(s)]
  
You can omit the quotes if there are no spaces in the search term.
+
*"REGEXP" can be any [[Regular Expression]]
If file is omitted, all files in current dir are searched.
+
*Single or double quotes can be used.
Multiple files can be specified separated by spaces or wildcarded (*.txt)
+
*Quotes can be omitted if there are no spaces in the search term.
'''While most tutorials assume that you are going to specify a file to search, using the search feature in vi makes more sense for working with a single file.'''
+
 
 +
*If file is omitted, all files in current dir are searched.
 +
*Multiple files can be specified separated by spaces or wildcarded (*.txt)
 +
*''While most tutorials assume that you are going to specify a file to search, using the search feature in vi makes more sense for working with a single file.''
  
-i  ignore case
+
OPTIONS:
-n  print line #s
+
-i  ignore case
-l  just show filenames
+
-r  recursive files inclusion
-x  exact matches only
+
-F  Fast search using literal search term, not regEx
-w  match whole words only
+
-n  print line #s
-m, --max-count=NUM      stop after NUM matches
+
-l  just show filenames
-a  text files only
+
-x  exact matches only
-r recursive files inclusion
+
-w  match whole words only
 +
-m, --max-count=NUM      stop after NUM matches
 +
-a  text files only
 +
   
 +
-iFr ignore case, simple string search, search current directory and subdirectories
  
 +
'''egrep''' is replaced with '''grep -E''')
 +
'''fgrep''' is replaced with '''grep -F''')
  
foo can be any [[Regular Expression]]
+
Can pipe the output of another command
 +
ls |grep blah lists all files in the current directory whose names contain the string "blah"
  
 +
==Create shortcuts in Linux (symbolic links)==
  
egrep supports pipes ("or") (= grep -E)
+
ln -s /pathToTarget nameOfTheLink
 
+
egrep "fruit|bread"
+
e.g.  ln -s /var/www/html/public_html/ webDirectory
 
+
ln creates hard and soft links. The -s option create soft (symbolic) links to resources in other directories, even other drives.
fgrep (fast grep, simple text, no RegEXp) (- grep -F)
+
 
+
Can pipe the output of another command
+
 
+
ls |grep blah lists all files in the current directory whose names contain the string "blah"
+

Latest revision as of 14:28, 12 September 2015

Personal tools
Namespaces

Variants
Actions
Navigation
Tools