Cheatography
https://cheatography.com
A quick entry point to do some tricks on Linux.
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Tree exloration
Go inside a directory |
|
List directory elements |
|
Print current directory |
|
List 10 biggers directories |
du -sh * | sort -h | tail
|
Find ksh scripts containing a pattern |
grep -R pattern . --include=*.ksh
|
Find all files older than 3 days |
find . -maxdepth 1 -type f -mtime +2
|
Process information
List the process tree of a user |
|
Check if a script is running |
|
File display
Print all the content file |
|
Print the first 20 lines |
|
Print the last 30 lines |
|
Print the last lines as the file grows |
|
Print the line number of a file |
|
|
|
File manipulation
Move a file from dir1 to dir2 |
|
Rename a file |
mv file_name new_file_name
|
Add execution permission for the user |
|
File manipulation in row
Split one line into several lines of a fixed size |
|
Union of file1 and file2 |
|
Intersection of file1 with file2 |
|
Exclusion of file2 from file1 |
|
File manipulation in column
Append a string at each start of line |
sed "s/^/start/" file
|
Append a string at each end of line |
|
Print columns 2 and 4 of a csv file |
|
Concatenate two files in column |
|
|