Last active
November 24, 2017 15:56
-
-
Save Link-/9865cd94be049bbfa02a to your computer and use it in GitHub Desktop.
Unix : Search & Rescue commands
This file contains hidden or 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
-- Find | |
egrep -Rl <regular expression> <file or files> | |
-- Find and Replace | |
grep -l '' ./* | xargs sed -i "" 's/IP4445A/IP445A/' | |
-- Find and Replace (no RegEx) | |
-- Add IMO number | |
grep -l '' ./* | xargs sed -i "" 's|MSC:172:20+++:146::VITNAME|MSC:172:20+++9299551:146::VITNAME|g' | |
-- Change VVN | |
grep -l '' ./* | xargs sed -i "" 's|TDT+20+533E+1|TDT+20+FX533E+1|g' | |
-- Copy Find | |
cp `egrep -Rl "IP445A" ./*` ../upload/ | |
-- Copy files in a list to a new location | |
-- OSX use -I / for other Linux distros use -J | |
cat list.txt | xargs -I % cp % /Users/bassemd/newFolder | |
-- Count files with a string match | |
ls -l | grep <STRING> | wc -l | |
-- Find files older than x days | |
find <directory> -name "*STRING*" -mtime +2 | |
find <directory> -mtime +2 | |
-- Find files older than x days and execute action | |
find <directory> -mtime +2 | wc | |
-- Execute action on each one of the files (here it's delete) | |
find <directory> -mtime +2 -exec rm {} \; | |
-- Reload terminal after edit of bash_profile | |
source ~/.bash_profile | |
-- Create an alias | |
alias <code>="command" | |
-- Dot files | |
ls -ld ~/.??* | |
-- Copy dotfiles | |
cp -R `ls -d /folder/.??*` target | |
-- Copy folder structure without files | |
rsync -a /path/from/ /path/to/ --include \*/ --exclude \* | |
-- Get the list of items NOT matching a specific regex | |
cat /usr/share/dict/words | grep -Ei '^[^z][a-z]+' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment