Here are some useful command line snippets
Get the number of files in a directory, by using the ls
command this will count the result.1
ls -l | wc -l
List all files in a directory/ directories recursively1
ls -LR
Find all files in a directory based on a pattern1
ls | grep -P "^A.*[0-9]{2}$"
And remove all files that match that pattern1
ls | grep -P "^A.*[0-9]{2}$" | xargs -d "\n" rm
Move multiple files to a directory1
mv -t path/to/DESTINATION file1 file2
OR Using a wildcard(*) to match file names
1 | mv *.jpg path/to/DESTINATION |
Decode a Base64 string in the command line1
echo < base64 string > | base64 --decode
Search your bash history1
history
Search the last N
number of results from you history1
history 5
Grep your history1
2history | grep <thing to search for>
history | grep ssh
Execute command found in history1
2!<history id>
!5