Lecture 7 - 14 Commands
Lecture 7 - 14 Commands
1. touch india.txt
touch a1.txt a2.txt a3.txt
# with location--->
1. touch /tmp/india.txt
===================================================================================
===========
------------------ lecture 9
---------------------------------------------------------------------
# cat ---> create file or read and write contant under file
cat
for write--->
# cat > myfile.txt
welcome to linux
hello india
welcome to aws cloud
for read--->
# cat myfile.txt
# for series---> cat -n myfile.txt
# put more contant in already exixt file ---> cat >> myfile.txt
hello kali linux
welcome azure cloud
===================================================================================
=======
# use of ; --> multipal commands execute in a single line or write more commands in
one line
===================================================================================
=============
/// # head ---> show by default 10 lines of any folder from top to bottam ///
---------------------------------------------------------------------
/// # tail ---> show by default 10 lines of any folder from bottam to top ///
/// Ques - passwd folder has 30 lines. So print only line 20 to 26 lines of passwd
folder. ///
1. head -n 25 /etc/passwd | nl ---> show top 25 lines of PASSWD folder using head
command
2. head -n 25 /etc/passwd | nl | tail -n 5 ---> manipulating the first command by
using pipe command (|) and print last 5 bottam lines of first command
---------- proved -------------------------------------------------------
# tail -F /var/log/messages
===================================================================================
====================
# echo "hello india" >> sanjay.txt ---> again print this message in sanjay.txt file
===================================================================================
======================
------------------>
# rename for file anf folder ---> rename { syntax --( old name new name old
name )}
example-->
1. mkdir india
2. rename india delhi india (old name new name old name)
3. ls
===================================================================================
===========
# ls
# touch abc ---> make file
# mkdir india ---> make file
# ls
# cp abc india --> copy abc file in india folder
# ls india/
# cp delhi india ---> error ( without options dir not copy )
# cp -r delhi india
# ls india/
# touch abc{1..10}
# ls
# cp -rvf abc{} india
# ls india/
# touch abc{11..20}
# ls
# cp -rvf abc{11..20} india
# ls india/
# touch abc{21..30}
# ls
# cp -rvf abc{21..30} india OR cp -rvf abc* india ---> copy all files start with
abc but overwrite every time (y,y,y...)
# cp -rvfn abc* india ---> "n" for no overwrite
# cd /etc
# ls
# cp -rvf * /root/india/
# ls
# cd india
# ls
-------------------------------------------------------------------
===================================================================================
==