nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Use "$BYTES" amount of RAM with no output | yes | tr \\n x | head -c $BYTES | grep n |
Send SIGTERM signal to any process which 'ps' lists as "python csp_build.py" | kill `ps ax | grep 'python csp_build.py' | awk '{print $1}'` |
Monitor all processes whose command includes 'process-name'. | top -p `pgrep process-name | tr "\\n" "," | sed 's/,$//'` |
List of directory & count of file in every directory | find . -maxdepth 1 -type d | while read -r dir; do printf "%s:\t" "$dir"; find "$dir" -type f | wc -l; done |
find files with the extension .conf in the /etc directory | find /etc -name '*.conf' |
Find deb packages in the current directory recursively | find . -type f -and -iname "*.deb" |
Delete orphan vim undo files in the current directory tree | find . -type f -iname '*.un~' | while read UNDOFILE ; do FILE=$( echo "$UNDOFILE" | sed -r -e 's/.un~$//' -e 's&/\.&/\1&' ) ; [[ -e "$FILE" ]] || rm "$UNDOFILE" ; done |
Search "file1" for lines matching regex patterns listed in "file2" and list the unique results | grep -f file2 file1 | sort | uniq |
Check whether "/full/path" is a mount point with no output and using the exit code | df /full/path | grep -q /full/path |
List all *.jpg files/directories in entire file system | find / -name "*.jpg" -print |
Search the current directory recursively for files containing "needle text" | find . -type f -print0 | xargs -0 grep -IZl . | xargs -0 grep "needle text" |
Print file system disk space usage in human readable format of the root filesystem | df -h / |
Count the number of files in the /usr/ports directory tree whose names begin with 'pkg-plist' and which contain 'etc/rc.d/' | find /usr/ports/ -name pkg-plist\* -exec grep -l etc/rc.d/ '{}' '+' | wc -l |
find all regular/normal files in the folder "pathfolder" and display the count of files, save all the errors to err.txt file | find pathfolder -type f 2> err.txt | wc -l |
find all the files in current directory of size greater than 10MB and less than 20 MB. | find . -size +10M -size -20M |
find directory names starts with 'bar' | find . -path './bar*' -print |
Print process tree, adjusting output width with a screen size. | pstree | cat |
replace the word apple with orange in all the regular/normal files in the current folder | find ./ -type f -exec sed -i -e 's/apple/orange/g' {} \; |
Append history lines from this session to the history list | history -a |
display all files in the current folder and do not search in the sub directories | find . -maxdepth 0 |
Print the name of "file1" if this file is newer than "file2" | find file1 -prune -newer file2 |
Find all files under $1 not matching the regex '.*/\..*' and execute hashmove on each of them with the file path as its argument | find $1 -type f -not -regex '.*/\..*' -exec $0 hashmove '{}' \; |
Print a time stamp for each successful ping to "host" | ping host | awk '{if($0 ~ /bytes from/){print strftime()"|"$0}else print}' |
display all the normal/regular files in the current folder and do not go beyond 3 levels | find . -maxdepth 3 -type f |
Show the date in default format for tomorrow + 2 days + 10 minutes | date -d tomorrow+2days-10minutes |
Find all files/directories owned by the user 'bob' under '/home' directory tree | find /home -user bob |
Find StringBuffer in all *.java files | find . -type f -name "*.java" -exec grep -l StringBuffer {} \; |
Checks that 'monit' user is in 'www-data' group. | groups monit |grep www-data |
search for the word "redeem reward" in all the regular/normal files in the current folder | find . -type f -exec grep -i “redeem reward” {} \; -print |
Search the current directory tree for regular files that were changed $FTIME days ago | find . -type f -ctime $FTIME |
run ls command on *.pl files | find . -name "*.pl" -exec ls -ld {} \; |
Find all files/directories that are owned by user 'dave' under current user's home directory tree | find ~ -user dave -print |
Prints lines count in each *.c file of a current folder and total count. | wc -l *.c |
find all the directories in the current folder excluding search in the sub directories and create these directories in another path | find . -maxdepth 1 -type d | xargs -I X mkdir '/new/directory/X' |
find not case sensitive all directories that names are 'apt' and display details | find / -type d -iname "apt" -ls |
display long list of all the perl files in the current folder | find . -name "*.pl" -ls |
display the number of lines in all the php files in the current folder | find -name '*php' | xargs cat | wc -l |
Mount "cpuset" filesystem on "/cpuset/" | mount -t cpuset none /cpuset/ |
change the owner and group of all the files in the folder /usr/lpp/FINANCIALS | find /usr/lpp/FINANCIALS -print | xargs chown roger.staff |
Join lines in file "aa" with lines in file "bb" if the lines share a common first word and sort the result numerically | join < < | sort -k1,1n |
Print unique lines of sorted file "file1" when compared with the list of first space separated fields of all sorted strings of file "file2" | cut -d' ' -f1 file2 | comm -13 - file1 |
Search /usr, /home, /tmp for *.jar files suppressing error messages | find /usr /home /tmp -name "*.jar" 2>/dev/null |
Create compressed archive from "my_large_file_1" and "my_large_file_2" and split into files of size 1024 MiB with prefix "myfiles_split.tgz_" | tar cz my_large_file_1 my_large_file_2 | split -b 1024MiB - myfiles_split.tgz_ |
Find all files that have the SUID bit set | find / -perm -u+s -print |
Unzip and extract "userAgent=[^=]*'" from "input.gz" | zcat input.gz | grep -o 'userAgent=[^=]*' | sed 's/ [^ ]*$//' |
Print local SRV record of domain '_etcd-client._tcp.' | dig @"127.0.0.1" _etcd-client._tcp. SRV |
find all the files in the current folder which do not have the read permission | find . -type f ! -perm -444 |
Find all *.rb files under current directory | find . -name "*.rb" -type f |
Find not-executable files under /home/www | find /home/www/ ! -executable |
Count the number of lines in all ".php" files in the current directory tree | wc -l `tree -if --noreport | grep -e'\.php$'` |
Find all files/directories under current directory following symlinks if needed | find -L |
Find all *.rpm files/directories under current directory | find . -name '*.rpm' |
Compress and display the gzip compression ratio of every file on the system that is greater than 100000 bytes and ends in ".log" | sudo find / -xdev -type f -size +100000 -name "*.log" -exec gzip -v {} \; |
Find *.c files under $HOME and search for the string 'sprintf' in those files | find $HOME -name '*.c' -print | xargs grep -l sprintf |
Find all *shp* directories under current directory and move all regular files inside those directories to ../shp_all/ | mv $(find $(find . -name "*shp*" -printf "%h\n" | uniq) -type f) ../shp_all/ |
Use 'top' to monitor the oldest instance of ProgramName. | top -p "$" |
Print a ping request and the number of packets sent, received, and the percentage lost for each ping request to "google.com" | ping google.com | awk '{ sent=NR-1; received+=/^.*(time=.+ ms).*$/; loss=0; } { if (sent>0) loss=100-((received/sent)*100) } { print $0; printf "sent:%d received:%d loss:%d%%\n", sent, received, loss; }' |
display all the ".c" files in the current folder excluding those that are present in all the sub directories | find . \( ! -name . -prune \) -name "*.c" -print |
search for the file test in the current folder | find . -name test |
Find all files under $YOUR_DIR | find $YOUR_DIR -type f |
Display differences between list of files in /bin and /usr/bin. | diff <(ls /bin) <(ls /usr/bin) |
Find all files in the /home/ directory tree that were last accessed more than 7 days ago | find /home -atime +7 |
search for the file "process.txt" in the current folder | find . -iname 'process.txt' -print |
Go to directory specified by variable "somedir", but replacing leading ~ character by actual home directory. | cd $(echo $somedir | sed "s#^~#$HOME#") |
Search for files greater than 20MB in the entire file system, sort them according to size in descending order and display the path and file size | find / -type f -size +20000k -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }' | sort -nrk 2,2 |
Delete all regular files named 'FindCommandExamples.txt' under current directory tree | find . -type f -name "FindCommandExamples.txt" -exec rm -f {} \; |
search for "message.txt" in the folder .cache/bower and display its contents | find .cache/bower/ -name "message.txt" | xargs cat |
Print all unique strings in $1.tmp file. | cat $1.tmp | sort -u |
Recursively find the latest modified file in the current directory | find . -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" " |
Print the last line of "$file1" to the console and append to "$file2" | tail -1 $file1 | tee -a $file2 |
set alias "cleanup" for command "rm -Rf -- foo bar baz" | alias cleanup='rm -Rf -- foo bar baz' |
Compare text "hello" and "goodbye" line by line | diff < < |
Print a NULL-separated list of all hidden regular files from the home directory | find $HOME -maxdepth 1 -type f -name '.*' -print0 |
Save to report.txt the first line of every text file in the home directory | find $HOME/. -name *.txt -exec head -n 1 -v {} \; > report.txt |
return every file that does not have bar somewhere in its full pathname | find . ! -path '*bar*' -print |
Create intermediate directories as required | mkdir -p $2 |
Copy "local_file" to "user@host:remote_file" via ssh protocol, saving partially transferred files, and showing progress | rsync -P -e ssh local_file user@host:remote_file |
Update timestamps of all files under current directory. | find . -exec touch {} \; |
List files greater than 1024KB under /path/to/directory and print the time and size on stdout | find /path/to/directory -type f -size +1024k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }' |
set alias "dosetit" for command 'eval `setit-sh`' | alias dosetit='eval `setit-sh`' |
search for "specified string" in all the php files in the current folder | find . -name “*.[php|PHP]” -print | xargs grep -HnT “specified string” |
Updates all software in system, prints update log on terminal and saves to 'mylogfile'. | yum update | tee mylogfile |
Set variable 'vara' to 3 | source <(echo vara=3) |
move files accessed more than one day ago to directory TMP | find . -atime +1 -type f -exec mv {} TMP \; # mv files older then 1 day to dir TMP |
Print list of disk and mountpoint of disks matching "/dev/sd*" | mount | awk '/\/dev\/sd/ {print NR, $1, $3}' |
Find files in the current directory recursively that are not readable by all | find -type f ! -perm -444 |
Find *.java files under current directory and compress them to myfile.tar | find . -type f -name "*.java" | xargs tar rvf myfile.tar |
Remove the "^M" characters from all *.ext files under /home directory | find /home -type f -name "*.ext" -exec sed -i -e "s/\r$//g" {} \; |
Find all files/directories with space in their names under /tmp/ directory and rename them by replacing all spaces with _ | find /tmp/ -depth -name "* *" -execdir rename 's/ /_/g' "{}" \; |
Shows MAC address of network interface eth0. | ifconfig eth0 | grep HWaddr |cut -dH -f2|cut -d\ -f2 |
display all the files in the current folder for the files which have not been accessed in the last 24 hours | find . -type f -atime +1 |
List files smaller than 9kB residing in the current directory and below | find . -size -9k |
display the count of all normal/regular files in current directory | find . -type f | wc -l |
Find all *.page (case insensitive) files/directories under current directory and run ~/t.sh for each of them with the file path as argument, then sort the output | find . -iname *.page -exec ~/t.sh {} \; | sort |
Find all files under /home/username/public_html/themes and set their permission to 640 | find /home/username/public_html/themes -type f -exec chmod 640 {} + |
Print a colon-separated list of all directories from the ~/code directory tree | find ~/code -type d | tr '\n' ':' | sed 's/:$//' |
display all the files in the file system excluding all the ".c" files | find / \! -name "*.c" -print |
Clears the terminal screen. | clear |
Find all regular files in the home directory tree that were modified in the last 24 hours | find ~ -type f -mtime 0 |
display all files in the folder bar only in the path /foo/bar/myfile (no output is generated) | find bar -path /foo/bar/myfile -print |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.