vim
Remove ^M
:%s/\r//g
Remove unwanted whitespaces
:%s/\s\+$//
Aligning text (using Tabular.vim)
:%sTab /,\zs
Replace tabs with spaces
:retab
bash
Determine target architecture of binary file
for i in $(ls); do objdump -x $i | grep 'Architektur:' | cut -d ' ' -f 2 | cut -d ',' -f 1; done
Unzip all files in this folder
for i in $(ls); do data=$(file --mime-type $i | cut -d ' ' -f 2); if [[ $data == 'application/zip' ]] then; unzip $i; fi; done
Retrieve all false positive hash values from Virustotal API report
for i in $( grep -n ' 0/' <file> | cut -f 1 | sed 's/://' ); do head -n $( echo $i + 2 | bc) <file> | tail -n 1 | awk '{ print $5 }'; done >> ../false_positives.txt
Find all files in sub directories from current location and move them there
find . -mindepth 2 -type f -print -exec mv {} . \;
Recursively change permissions of files
sudo find <path> -type f -print0 | xargs -0 sudo chmod 644 -
sudo find <path> -type d -print0 | xargs -0 sudo chmod 755 -
Find specific files in same directory and remove them
find . -size 0 -print0 | xargs -0 rm
find . -size +30M -print0 | xargs -0 rm
Iterate over a list of filenames and remove them
for i in $(cat ../false_positives.txt); do if [[ -e $i ]]; then rm -v $i; fi; done
Delete all directories in current location
rm -R -v -- */
Kill apache2 process
kill -9 $(ps -e | grep apache2 | awk '{print $1}')
Count history commands and return them
history | cut -c8- | sort | uniq -c | sort -rn | head
Exclude files from search by file type
grep -rn <search> --exclude=\*.{log,swp} <folder>
To determine the path that your system has assigned to the new hard drive
sudo lshw -C disk