Top Unix File Commands to Create, Edit, Delete, Modify

Top Unix File Commands to Create, Edit, Delete, Modify


I provide you list of Unix commands. These commands asked me when I gave an interview. So I determined these commands to share with you.

Unix File Create, Edit, Modify, DELETE commands

>> vi myfile.txt

The above command useful to create new file.

>> rm abc.txt

The above command deletes specified file.

>> vi myfile.txt

The above command useful to modify or edit its contents.

>> mv abc.txt cde.txt

The above command useful to Modify or Rename a file name.

The other way when you are new to UNIX the tips given in UNIX/Linux Operating system – Beginner to Advanced really give lot of benefits. Working on the files is very common practice for data warehousing developers.

Unix File Editing Commands

$> head -1 sample.txt :=> To get top one line
$> sed ‘2,$d’ sample.txt :=> To get first 2 lines
$> tail -1 sample.txt :=> To get last one line
$> tail -n ‘2p’ sample.txt :=> To get 2nd line of file
$> head -4 sample.txt | tal -1 :=> To get fourth line of file
$> sed ‘1d’ sample.tx :=> To remove first line of file
$> sed -i ‘1d’ sample.txt :=> After deleting update the same file
$> sed -i ‘5,7d’ sample.txt :=>Remove lines from 5 to 7
$> sed -n ’35p’ sample.txt | wc -c :=>
To get 35 number of chars in any line of the file
$> cut -f4 -d ‘ ‘ ==> To get 4th word from each line of file delimiter is spaces
$> echo ‘unix’ | rev : ==> To get word in reverse – xinu
$> unzip -j sample.txt :=> To unzip a file
$> file -i file.zip :=> To get information about file