General File Commands

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

General file commands

$read variable-name

$echo “pec uni”

$wc abc (word count---in file abc)

FILE ACCESS PERMISSIONS

$chmod +x abc (to grant permission to file abc to execute (x))

$chmod -x abc (revoking the permission)

R – read

h- hide

$chmod 777 abc (for granting all permissions to file abc)

PIPES (mechanism which takes output of a command as its input for the next
command)
$who |wc (output from who is input of wc -------then result is displayed)

PIPES PREVENTS US FROM MAKING TEMPORARY FILES

FILTERS
To extract lines which contain a specific pattern

To arrange the contents of a file in sorted order

Replace the existing characters with some other characters

To store intermediate results of a long pipe

Merge 2 or more file together using filters

2 types

1. GREP
2. SORT – to sort in alphabetical order
 $sort
Abc
Xyz
Ctrl+d
(press enter ---- result is in sorted order)
 $sort –r (in reverse alphabetical order)
 $sort –f (to ignore the case distinction)
 $sort –n (to sort numbers)

GREP (global search for regular expressions)-----extracts data from file

$grep “pec” abc (searches for lines containing pec in file abc and displays them)

$grep “b$” abc (extracting lines that end with b in file abc and displays them)

$grep “^t” abc (extracting lines that start with t in file abc and displays them)

$grep “pec|uiet|ccet” abc (for multiple lines search)

Fgrep ---------fixed grep,,,extracts only fixed strings

$fgrep “pec is a” abc (only those lines which contain this string as a whole)

Egrep----------extended grep -----------to lok out a pattern

$egrep “(ica)$” abc (searches for the string ica in the file abc , it may be in any word also)

You might also like