Sunday, May 15, 2011

Simple Commands on Linux(shell scripting in unix)

1- how open new file in shall
- vi  file-name.sh
after opening a new file, for inserting command press : shift+i
for saving the commands in  file and  exit press: ESC+Shift+: +q

2- how delete special lines(rows)  from one file :

after pressing Esc+Shift+:   type :  1,1990d  and then press enter
with this command rows from 1 to 1990 will be delete from that file.

3- Running an batch file :
- first set permission for  running with the following command:
           - chmod 777(or 755)  filename.sh
- now run with the following command :
           - ./ filename.sh

for displaying list  just  run the following command :
        - LS

4- copying favorite number of lines from one file to other :
     head -1000 file2.txt > file3.txt
with  this command 1000  rows  from  file2.txt will be  copy to file3.txt.


all the best.


No comments:

Post a Comment