nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Search the system for files and directories owned by group `managers'
find / -group managers -print
Close the master SSH control socket "my-ctrl-socket" to "[email protected]"
ssh -S my-ctrl-socket -O exit [email protected]
Print the top 10 commands with their use count
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -nr | head
find all the wav files in the current folder and do not search in the sub directories
find . -name '*.wav' -maxdepth 1
Delete all regular files named 'IMAGE1806.jpg' under current directory tree
find . -type f -name 'IMAGE1806.jpg' -delete
set alias "foo" for command 'BAR=baz'
alias foo='BAR=baz'
Connect to port 2222 of example.com as ssh user "user", and copy local file "/absolute_path/source-folder/some-file" to remote directory "/absolute_path/destination-folder"
scp -P 2222 /absolute_path/source-folder/some-file [email protected]:/absolute_path/destination-folder
find all the files in the current folder and display adding quotations to each file and replace spaces with new line
find $PWD -exec echo -n '"{}" ' \; | tr '\n' ' '
Archive all filepattern-*2009* files/directories under data/ into 2009.tar
find data/ -name filepattern-*2009* -print0 | xargs -0 tar uf 2009.tar
display a list of all java or jsp files in the current folders
find . \ -type f -ls
Shows only process trees rooted at processes of this user.
pstree user
Extract any line in "file1.txt" which does not appear as the first ";" delimited entry in "file2.txt"
comm -23 < <
find all the files that were modified yesterday in the current directory.
find . -daystart -ctime 0 -type f
display all the text files in the current folder
find . -name "*.txt" -print
Find all regular files under $d directory tree and change their permissions to 777
find "$d/" -type f -print0 | xargs -0 chmod 777
Search the current directory tree for files executable by at least someone
find . -type f \ -exec test -x {} \; -print
Print disk of mount point "/pa/th"
mount | awk '$3 == "/pa/th" {print $1}'
Puts the job 1 in the background.
bg %1 [puts the job in the background]
find all the php files in the current folder
find . -name “*.[php|PHP]” -print
Find all regular files in and below the home directory that have been modified in the last 90 minutes
find ~ -type f -mmin -90
Find broken symlinks
find ./ -follow -lname "*"
Add a line number to every line in "long-file"
nl -ba long-file \
find symbolic links with pattern` '*sysdep.c'
find . -lname '*sysdep.c'
Lists all subdirectories in the current directory with the trailing slash removed
ls -d1 */ | tr -d "/"
Prints help on 'cp' utility.
cp --help
show the disk use of all the regular/normal files in the current folder which are bigger than 50MB
find . -type f -size +50000k | xargs du -sh
Find all the files which were modified 50 days ago
find / -mtime 50
Print unique lines of sorted file "A.txt" compared to sorted file "B.txt"
comm -23 <(sort -u A.txt) <(sort B.txt)
Delete files in the DIR directory tree whose names begin with "2015" and contain "album" or "picture"
find DIR \( -name 2015\* -a \ \) -delete
Replace all colons with newlines in $list and search for the first match to the regex "^$removepat\$" where $removepat is a variable and save the result to variable 'removestr'
removestr=$
Read a line from standard input with prompt "<Your Friendly Message here> : y/n/cancel" and save the response to variable "CONDITION"
read -p "<Your Friendly Message here> : y/n/cancel" CONDITION;
Search for 'Text To Find' in all regular files under current directory tree and show the matched files
find ./ -type f -exec grep -l "Text To Find" {} \;
create a link to all the html or htm files in the current folder which have been changed in the last 30*24 hours
find \ -a -ctime -30 -exec ln {} /var/www/obsolete \;
find all files and directories under the current directory and display the inode of each one, using the stat command on FreeBSD/OSX
find . -print0 | xargs -0 stat -f '%i '
display all the regular files in the current folder that are exactly 10KB
find . -type f -size 10k
find all the normal/regular files in the current folder which have been accessed in the last 24 hours and display a long listing of them
find . -type f -atime -1 -exec ls -l {} \;
Save IP addresses of the host name in variable "ip"
ip=$
Find all $2 files in $1 path and search for the regex expanded by $3 in those files excluding the files with /proc in their paths
find $1 -name "$2" | grep -v '/proc' | xargs grep -Hn "$3" {} \;
Read a line from standard input into variable "ans" without backslash escapes
read -r ans
Find all files/directories named 'articles.jpg' under '/home/username/public_html/images' directory tree
find /home/username/public_html/images -name "articles.jpg"
Gets IP addresses of all network interfaces.
ifconfig | grep ad.*Bc | cut -d: -f2 | awk '{ print $1}'
List *.txt files residing in the current directory tree
find . -name *.txt -exec ls {} ;\
Print the physical current working directory
echo "`pwd -P`"
Make directories "a", "b", "c", "d", and "e"
mkdir a b c d e
Find all empty directories in minimum 2 levels down the root directory
find root -mindepth 2 -type d -empty
Search the home directory for files whose names begin with "test"
find ~ -name "test*" -print
Join lines of 'file': fields 1 and 2 of lines discarding adjascent lines ignoring first 3 fields, with fields 3 to end of line discarding adjascent lines ignoring 3 last fields.
paste < <
remove all "Foo*" files under current dir
find . -type f -name "Foo*" -exec rm {} \;
Find all directories that do not contain "main.cpp"
diff <(find . -exec readlink -f {} \; | sed 's/\(.*\)\/.*$/\1/' | sort | uniq) <(find . -name main.cpp -exec readlink -f {} \; | sed 's/\(.*\)\/.*$/\1/' | sort | uniq) | sed -n 's/< \(.*\)/\1/p'
Check if directory $some_dir is empty
find "$some_dir" -prune -empty -type d | read && echo empty || echo "not empty"
Save the system load average for the past 1 minute of the currently logged in user to variable 'proc_load_average'
proc_load_average=$(w | head -1 | cut -d" " -f12 | cut -d"," -f1-2 | tr ',' '.')
Recursively finds all '*.pdf' files in a current folder and removes them.
find . -name '*.pdf' -exec rm {} +
change owner of the files into directory "/mydir" with ".txt" extension to user root
find /mydir -type f -name "*.txt" -execdir chown root {} ';'
find all files in the folder /path/to/dir which have been modified between two dates
find /path/to/dir -newermt yyyy-mm-dd ! -newermt yyyy-mm-dd -ls
find all the files in the folder "/mp3-collection" which are bigger than 10MB excluding those that start with the word Metallica
find /mp3-collection -size +10000k ! -name "Metallica*"
Find .cpp files that differs in subdirectories PATH1 and PATH2.
diff -rqx "*.a" -x "*.o" -x "*.d" ./PATH1 ./PATH2 | grep "\.cpp " | grep "^Files"
Find all files in the current directory аргумент and its sub-directories with the optional constraints of опция_поиска, значение and/or значение.
find аргумент [опция_поиска] [значение] [значение]
Print a count of files and directories in the current directory tree
tree | tail -1
find all the files in the current folder which have been changed in the last 60 minutes
find . -cmin -60
change the ownership of all the files in the file system from edwarda to earnestc
find / -user edwarda -exec chown earnestc "{}" \;
display the names without extensions of all the data files in current folder which have not been changed in the last 60 mins
find ./ -name "*.dat" -type f -cmin +60 -exec basename {} \;
Print only alphanumeric values from "/dev/urandom"
cat /dev/urandom | tr -dc 'a-zA-Z0-9'
Pipe output of "yes" to "more" and append the first 3 lines to "file"
yes | awk 'FNR<4 {print >>"file"; close} 1' | more
Print a line of 3 '%' characters
seq -s % 4|tr -d '[:digit:]'
find all files in the file system which have no user and no group
find / -nouser -nogroup
Execute "wget -qO- http://fake.link/file.txt" every 5 seconds
watch -n 5 wget -qO- http://fake.link/file.txt
Search for 'DOGS' in all files with '.txt' extension under ~/documents and also print the file names
find ~/documents -type f -name '*.txt' -exec grep -s DOGS {} \; -print
Find the empty directories and files under current directory
find -empty
search for a word in all the regular files in the current folder without traversing the sub directories .
find -maxdepth 1 -type f | xargs grep -F 'example'
Source executable "virtualenvwrapper.sh" found in $PATH
source `which virtualenvwrapper.sh`
find file which case-insensitive name is too in currect directory
find . -iname foo
Search the home directory tree for files last modified less than 2 days ago or newer than file "filename"
find ~/ -mtime -2 -o newer filename
Find regular non-hidden files containing 'some text' in their names
find . -not -path '*/\.*' -type f -name '*some text*'
Update the archived copy of the home directory, "alldata.tar"
find ~/ -newer alldata.tar -exec tar uvf alldata.tar {} ;
Recursively removes all files like '*.pyc' in a current folder, printing info message about each action.
find . -name "*.pyc" | xargs -I {} rm -v "{}"
Print whether the unique contents of "set1" and "set2" differ
diff -q < <
Search directories /res/values-en-rUS and /res/xml for XML files
find /res/values-en-rUS /res/xml -iname '*.xml'
Calculate md5 sum of file ${my_iso_file} and save it to variable 'md5'
md5=`md5sum ${my_iso_file} | cut -b-32`
find the file "MyCProgram.c" in the current folder
find -iname "MyCProgram.c"
display the count of number html files in the current folder
find . -name "*.html" -print | xargs -l -i wc {}
search for all the directories in a folder and limit the search to current folder and give them as input to the python script
find /stuff/* -type d -maxdepth 1 -print0 | xargs -0 script.py
Search for file "file" between level 2 and 3 of the directory tree
find -mindepth 2 -maxdepth 3 -name file
List in detail all *.txt files in the current directory tree, omitting paths ./Movies/*, ./Downloads/*, and ./Music/*
find . -type f -name "*.txt" ! -path "./Movies/*" ! -path "./Downloads/*" ! -path "./Music/*" -ls
Save a random 4 byte unsigned integer from "/dev/urandom" to variable "RAND"
RAND=`od -t uI -N 4 /dev/urandom | awk '{print $2}'`
Search the current directory recursively for files writable for `others'
find . -perm -o+w
list in long format all files from / whose filename ends in "jbd", not descending into directories that are not readable while searching.
find / \! -readable -prune -o -name '*.jbd' -ls
Creates alias for network interface 'eth0' with IP address '192.0.2.55' and network mask '255.255.255.255'.
ifconfig eth0:fakenfs 192.0.2.55 netmask 255.255.255.255
Recursively change the owner and group of "/home/el/svnworkspace" and "775" to "your_user_name"
chown -R your_user_name.your_user_name 775 /home/el/svnworkspace
find all the files that were updated in the last 24 hours
find / -mtime -1
search for all the files in the current folder which have spaces, save the output of a file and save the long listing of these files to a log file
find . -name "filename including space" -print0 | tee my_teed_file | xargs -0 ls -aldF > log.txt
List each subdirectory name composing the current working directory
pwd | cut -f 1- -d\/ --output-delimiter=$'\n'
Cuts off last part from the path $dir, and deletes resulted folder if empty.
rmdir "$"
Print "file1.txt" "file2.txt" and "file3.txt" with filename headers
tail -n +1 file1.txt file2.txt file3.txt
Gets MAC address of en0 network interface.
ifconfig en0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'
FInd files in current directory and grep text and html files - but not index.html and report things that contain the word 'elevator' in four or more lines
find . -type f -print0 | egrep -iazZ '(\.txt|\.html?)$' | grep -vazZ 'index.html' | xargs -n 1 -0 grep -c -Hi elevator | egrep -v ':[0123]$'
Remove all *.mp3 files in tmp directory but not in it's subdirectories
find tmp -maxdepth 1 -name '*.mp3' -maxdepth 1 | xargs -n1 rm
Creates temporary file and saves path to it in 'content_dir1' variable.
content_dir1=$
Print which files differ in "dir_one" and "dir_two" recursively and sort the output
diff -qr dir_one dir_two | sort
Delete all lines matching "some string here" in "yourfile"
sed --in-place '/some string here/d' yourfile
recursively look for files ending in either .py or .py.server
find . \( -name "*.py" -o -name "*.py.server" \)