Unix Commands Flashcards Preview

Interview Prep > Unix Commands > Flashcards

Flashcards in Unix Commands Deck (30):
1

Basic utilities are

grep, sed, awk, etc

2

grep stands for

global regular expression print

3

basic grep command

grep "searchtext" filename

4

grep -n "searchtext" filename

shows the matched text with line numbers

5

grep -vn "searchtext" filename

shows the results and the lines that don't match the searchtext

6

grep - c "searchtext" filename

suppress printing of the matching lines but display only the number

7

grep -l "searchtext" *

shows the file name in which the searchtext is found

8

grep -i "SEARCHTEXT" filename

ignores the case and displays the results

9

grep -x "searchtext" filename

displays only the exact match

10

grep -A2 "searchtext" filename

displays the matched text plus additional two rows

11

% ls

lists the contents of your current working directory whose name doesn't begin with a dot (.)

12

% ls -a

to list all files in your home directory including those that begin with a dot (.)

13

% mkdir

to make a sub directory

14

% cd

to change to a directory

15

% cd .

in unix . means current directory. this command is to stay in the same directory

16

. .

two dots means parent of the current directory

17

% cd ..

will take you one directory up the hierarchy

18

print working directory

pwd

19

% pwd

prints the full path of the working directory

20

% cd ~

change to home directory; same as cd

21

% cd . .

change to parent directory

22

cp file1 file 2

copy file1 and call it file2

23

mv file1 file2

move or rename file1 to file2

24

rm file

remove a file

25

rmdir directory

remove a directory

26

cat file

display a file

27

more file

display a file one page at a time

28

head file

display the first few lines of a file

29

tail file

dsplay the last few lines of a file

30

wc file

count the number of lines/words/characters in file