Using cat command:
[root@dev ~]# cat > filename1
This is world file Ctrl+d (To save the file)
To display the content of the file
[root@dev ~]# cat filename1
This is world file
To display the content of the file
[root@dev ~]# cat >> filename1
This second line
[root@dev ~]# cat filename1
This is world file This second line
Creating multiple files at same time using touch command
[root@dev db_bak]# touch file{1..5}
[root@dev db_bak]# ls
file1 file2 file3 file4 file5
Creating a Directory:
[root@dev db_bak]# mkdir dir1
[root@dev db_bak]# ls
dir1
Making multiple directories inside a directory
[root@dev ~]# mkdir -p technology/{linux/{shell_script,linux},java/{basic,adv_java},mysql/{DBA,Dev}}
[root@dev ~]# tree technology/
technology/
|-- java
| |-- adv_java
| `-- basic
|-- linux
| |-- linux
| `-- shell_script
`-- mysql
|-- DBA
`-- Dev
9 directories, 0 files
Copying files into directory
[root@dev ~]# ls
filename
[root@dev ~]# cp filename technology/
[root@dev ~]# ls
filename
[root@dev ~]# cd technology/
[root@dev technology]# ls
filename java linux mysql
Copying directories from one location to other
[root@dev technology]# cp -rvfp java linux/
‘java’ -> ‘linux/java’
‘java/basic’ -> ‘linux/java/basic’
‘java/adv_java’ -> ‘linux/java/adv_java’
[root@dev technology]# cd linux/
[root@dev linux]# ls
java linux shell_script
Moving files from one location to other (cut and Paste)
[root@dev technology]# ls
filename java linux mysql
[root@dev technology]# mv filename java/
[root@dev technology]# cd java/
[root@dev java]# ls
adv_java basic filename
Moving a Directory from one location to other
[root@dev technology]# ls
java linux mysql
[root@dev technology]# mv java/ linux/
[root@dev technology]# ls
linux mysql
[root@dev technology]# cd linux/
[root@dev linux]# ls
java linux shell_script
Renaming a File
[root@dev linux]# ls
java linux shell_script
[root@dev linux]# mv linux/ linux_adv
[root@dev linux]# ls
java linux_adv shell_script
rm: remove regular empty file ‘file’? y
No comments:
Post a Comment