nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
create a backup of all the files in the file system which belong to the suer edwarda to the floppy | find / -user edwarda -print | cpio -ovBc > /dev/rfd0 |
Recursively search for everything under the current directory, displaying human-readable file type description for each entry. | find . -exec file {} \; |
List files smaller than 9kB residing in the current directory and below | find . -size -9k |
Find all *.bmp files in the current directory tree and convert them to the JPEG format | find -name *.bmp -type f -exec convert '{}' '{}'.jpg \; |
Numerically sort file "temp.txt" by the second "-" separated value of each line ordered from highest value to least value | tac temp.txt | sort -k2,2 -r -u |
check readline bindings for "\x61" | bind -p | grep $'"\x61"' |
Get the disk space used by all *.txt (case insensitive) files/directories under folder 1 and folder2 | find folder1 folder2 -iname '*.txt' -print0 | du --files0-from - -c -s | tail -1 |
Print lines 16225 to 16482 in file "file" | cat file | head -n 16482 | tail -n 258 |
Find all directories under $path | find $path -type d |
search for files in current folder using name patterns | find . -name "S1A*1S*SAFE" |
find all regular file and create jw-htmlfiles.tar | find . -type f -name "*html" | xargs tar cvf jw-htmlfiles.tar - |
Print a list of unique users who are logged in | who | cut -d' ' -f1 | sort | uniq |
Finds IP address of 'en0' network interface. | ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}' |
Find files named "AssemblyInfo.cs" in the current directory and below, and run "git diff --name-status" on them | find . -name AssemblyInfo.cs | xargs git diff --name-status -- |
Get a two column list of all regular .rb files residing in the current directory tree | find . -name "*.rb" -type f -print0 | xargs -0 -n 2 echo |
download contents from "http://url" using a proxy server | curl -x http://proxy_server:proxy_port --proxy-user username:password -L http://url |
Execute "awk -F, '$1 ~ /F$/'" on contents of "file.gz" | zcat file.gz | awk -F, '$1 ~ /F$/' |
Print string "123" once with '1' replaced by 'a' and second time replaced by 'b' | echo 123 | tee > | tr 1 b |
Print the average time of 4 ping requests to "www.stackoverflow.com" | ping -c 4 www.stackoverflow.com | awk -F '/' 'END {print $5}' |
Find all empty files in /tmp | find /tmp -type f -empty |
Print only strings from file 'file2' that not found in 'file1' | comm -1 -3 file1 file2 |
List all functions defined in the shell | set | grep " $" | cut -d' ' -f1 |
Split "/usr/bin/gcc" into 100000 files of about equal size | split -n 100000 /usr/bin/gcc |
Find all files/directories under current directory and print their paths | find . -exec echo {} \; |
Search all the *.pl files in the current directory and subdirectories, and print the names of any that don't have a line starting with 'use strict' | find . -name '*.pl' | xargs grep -L '^use strict' |
Save only the digits in "$filename" to variable "number" | number=$ |
find md5sum of 'string to be hashed' | md5 -s 'string to be hashed' |
Find all 400 permission files under /data directory and print 'Modifying ' appended with file path for each of them | find /data -type f -perm 400 -exec echo Modifying {} \; |
search for all the regular files in the folder /home which have the permission 077 | find /home -type f -perm 0777 -print |
Display the named characters in "Test\rTesting\r\nTester\rTested" | echo -e "Test\rTesting\r\nTester\rTested" | awk '{ print $0; }' | od -a |
remove all "Foo*" files under current dir | find . -type f -name "Foo*" -exec rm {} \; |
find the file "httpd.log" in the folder /home/web-server/ | find /home/web-server/ -type f -iname httpd.log |
Search the current directory tree for all files except SVN ones | find . ! -regex ".*[/]\.svn[/]?.*" |
Count the number of all directories under directory '/mount/point' non-recursively | find /mount/point -maxdepth 1 -type d | wc -l |
Print list of disk and mountpoint of disks matching "/dev/sd*" | mount | awk '/\/dev\/sd/ {print NR, $1, $3}' |
set alias "histgrep" for command "history | grep" | alias histgrep="history | grep" |
Prints line count of each file within current directory. | find . -type f -print0 | xargs -0L1 wc -l |
Recursively finds files like 'example.com', ignoring case differences, and filters out files with 'beta' in path. | find -iname example.com | grep -v beta |
Print a line of 10 '#' characters | seq -f "#" -s '' 10 |
Recursively find all files ending with '*.txt' and print they names and content | find . -name \*.txt -print -exec cat {} \; |
display all the normal/regular files in the current folder which are empty | find . -type f -empty |
Move all files matching case insensitive ".cpp" in the current directory tree to "./test/" | find . -type f -iname '*.cpp' -exec mv -t ./test/ {} \+ |
Mount the "vboxsf" filesystem "myFileName" on "~/destination" | sudo mount -t vboxsf myFileName ~/destination |
use find -exec with multiple commands | find . -name "*.txt" -exec echo {} \; -exec grep banana {} \; |
Perform case insensitive search for *.gif files/directories under downloads directory | find downloads -iname "*.gif" |
Sets 'extglob' shell option. | shopt -s extglob |
Prints path to folder that contains target of the symbolic link ../../../../etc/passwd. | $(dirname $) |
extract "passwd.tar.gz" with verbose output | tar -xvzf passwd.tar.gz |
Display total apparent size of a file | du -sb |
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 |
Create intermediate directoriy path2 as required and directories a..z | mkdir -p path2/{a..z} |
Recursively finds and compresses all files in a current folder with 4 parallel processes. | find . -type f -print0 | xargs -0 -n1 -P4 bzip2 |
Add prefix like number and "^M${LOGFILE}> " to every non-blank line received on standard input | nl -s"^M${LOGFILE}> " |
Compress all files under /source directory tree using gzip with best compression method | find /source -type f -print0 | xargs -0 -n 1 -P $CORES gzip -9 |
Find all *.jpg files in */201111 paths | find */201111 -name "*.jpg" |
Find files in the current directory tree whose names are of the form "cxx_data.txt" where xx is a number from 40 to 70 | find . -regextype posix-egrep -regex "./c(|70)_data.txt" |
Shows size of compressed file in .bz2 archive. | bunzip2 -c bigFile.bz2 | wc -c |
Sort "some_data" by the first and second ";" delimited entries, outputing unique lines and stabilizing the sort | sort -k1,1 -k2,2 -t';' --stable --unique some_data |
Print '"HTTP/1.1 200 OK', two new lines and the current date | echo -e "HTTP/1.1 200 OK\n\n $(date)" |
display all the doc files in the current folder | find . -name '*.doc' |
Rename all .jpg files to .jpeg under the current directory and below | find | rename 's/\.jpg$/.jpeg/' |
Counts the total number of lines in all the files in a git repository. | git ls-files | xargs cat | wc -l |
search for the file in the entire file system which has the words "filename" in its name | find / -name ”*filename*” |
Find all php files that belong to user 'takuya' and have been modified in the last 1 day | find -user takuya -name '*.php' -daystart -mtime -1 |
Save the canonical filename of "$BASH_SOURCE" in variable "me" | me=$ |
search for the file filename in the entire file system | find / -name filename |
Search the /root directory recursively for the regular file named "myfile" ignoring "work" directories | find /root/ -name 'work' -prune -o -name myfile -type f -print |
find directories that have been modified in the last seven days | find . -mtime -7 -type d |
find all log files larger then 100MB in /home directory and delete them . | find /home -type f -name *.log -size +100M -exec rm -f {} \; |
Print the current working directory with resolved symbolic links | pwd -P |
Save count of lines from file $file matching with pattern $filter and not matching with pattern $nfilter in variable 'totalLineCnt' | totalLineCnt=$; |
Find an inode and remove | find . -inum 968746 -exec rm -i {} \; |
Print the difference between line 2 and 3 in file "$f" | diff <(fold -w1 <(sed '2q;d' $f)) <(fold -w1 <(sed '3q;d' $f)) | awk '/[<>]/{printf $2}' |
Reformat date "Sat Aug 09 13:37:14 2014 +1100" according to format string "%a %b %d %H:%M:%S %Y %z" | date -j -f "%a %b %d %H:%M:%S %Y %z" "Sat Aug 09 13:37:14 2014 +1100" |
find all the files under '/usr/local' directory tree which have been modified exactly 24 hours ago | find /usr/local -mtime 1 |
Finds binaries names in a list of running processes and prints containing folder of each binary. | ps aux | awk '{print $11}' | grep -x -e "/.*" | xargs -I file dirname "file" |
Find all files in the current directory tree and count them | find | wc -l |
Print every three lines of "file" as a comma separated line | paste -sd',,\n' file |
Search regular files from the /path/to/dir directory tree for lines that contain "_START" and are enclosed in lines "@GROUP" and "@END_GROUP" | find /path/to/dir -type f -exec sed '/@GROUP/,/@END_GROUP/!d' {} \; | grep '_START' |
Print what year it was 222 days ago | date '+%Y' --date='222 days ago' |
Page through the contents of yourFile, adding a $ at the end of each line. | cat -e yourFile | less |
Count the number of total files and folders under current directory tree | find . -print0 | tr -cd '\0' | wc -c |
find all the files in the current folder whose name starts with 2 alphabets and ends with 2 digits. | find . — name "[a‑z][a‑z][0—9][0—9].txt" — print |
show all the files in the current folder excluding those from the directories whose name starts with "git" | find . -type d -name '.git*' -prune -o -type f -print |
display all the text files in current folder | find . -name "*.txt" -printf "%f\n" |
Search through the /usr directory for all files that begin with the letters Chapter, followed by anything else. | find /usr -name "Chapter*" -type f |
Displays details about package 'zsh'. | yum info zsh |
Format "file.txt" as space separated columns 28 characters in width | cat file.txt | column -c 28 -s "\ " |
Print short TXT record of domain o-o.myaddr.l.google.com from nameserver 8.8.8.8 | dig TXT +short o-o.myaddr.l.google.com @8.8.8.8 |
Print a list of regular files from directory tree sort_test/ sorted with LC_COLLATE=en_US.UTF-8 | find sort_test -type f | env -i LC_COLLATE=en_US.UTF-8 sort |
Locate all *.txt files in the current directory tree | find . -name "*.txt" |
Count the number of non localhost users | who | grep -v localhost | wc -l |
Search the /home/pankaj directory for regular files whose status has changed within the last 5 minutes | find /home/pankaj -maxdepth 1 -cmin -5 -type f |
display all the files in the current folder that have been modified in the last 24 hours | find -mtime -1 |
Remove all *.tmp files from the /tmp directory tree | find /tmp -name "*.tmp" | xargs rm |
Count the number of lines in "myfile.txt" | cat myfile.txt | wc -l |
Print the path composed of the current working directory and the directory containing "$0" | echo `pwd`/`dirname $0` |
Running "script" outputs the name of a directory, go into that directory. | cd `script` |
display all the php files in the entire file system | find / -name "*.php" |
Recursively change ownership of "~/.npm" to the current user | sudo chown -R `whoami` ~/.npm |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.