Last active
September 24, 2019 06:57
-
-
Save CRUZEAAKASH/b1b2730a7c9421d007062147be50e9d1 to your computer and use it in GitHub Desktop.
Linux Commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''''''''''''''''''''''''''''''''''''''''''''' | |
'''UseFul Linux Command | |
''''''''''''''''''''''''''''''''''''''''''''' | |
1. To take backup of a file or copy paste a file from one location to another | |
cp <Filepath/filename> <filepath/filename.bak> | |
2. To copy all the sub-directories also, use -r with cp command | |
cp -r <Filepath1/filename1> <filepath2/filename2> | |
3. TO find file or directory(case insensitive search) | |
find -iname "file or directory name" | |
4. To remove/Move file | |
mv <filename1> <path/filename2> | |
5. To check if Directory is present | |
if [[ -d DirectoryName ]] | |
then "directory does exist" | |
fi | |
6. $# represents the command line arguments | |
7. not eqals is represented by ne | |
eg. to check if the commandl line arguments are equal to 14 or not | |
if [[ $# -ne 14 ]] | |
then | |
echo "Commnad lines are not equal to 14" | |
else | |
echo "Arguments are 14 in length" | |
fi | |
8. Command line arguments are represented by $1, $2, $3 and so on. | |
After $9 the arguments must be enclosed in brackets, for example, ${10}, ${11}, ${12} | |
9. To get the date in format of YYYYMMDD | |
date +%Y%m%d | |
eg date +%Y%m%d will print 20190924 | |
10. To get the date in format of HourMinuteSecond | |
date +%H%M%S | |
eg date +%H%M%S will orint 122659 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment