Answers for "File Manupilation in linux"

0

File Manupilation in linux

Create an empty text file called myFile:
touch myFile

Rename myFile to myFirstFile:
mv myFile myFirstFile

View the contents of a file:
cat myFirstFile

View the content of a file with pager (one screenful at a time):
less myFirstFile

View the first several lines of a file:
head myFirstFile

View the last several lines of a file:
tail myFirstFile

Edit a file:
vi myFirstFile

See what files are in your current working directory:
ls

Create an empty directory called myFirstDirectory:
mkdir myFirstDirectory

Create multi path directory: (creates two directories, src and myFirstDirectory)
mkdir -p src/myFirstDirectory

Move the file into the directory:
mv myFirstFile myFirstDirectory/

You can also rename the file:
mv myFirstFile secondFileName

Change the current working directory to myFirstDirectory:
cd myFirstDirectory

Delete a file:
rm myFirstFile

Move into the parent directory (which is represented as ..):
cd ..

Delete an empty directory:
rmdir myFirstDirectory

Delete a non-empty directory (i.e. contains files and/or other directories):
rm -rf myFirstDirectory
Posted by: Guest on May-29-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language