nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Find all *.java files under current directory containing the string 'String' | find . -name "*.java" -exec grep "String" {} \+ |
Archive "src-dir" to "dest-dir" on "remote-user@remote-host" and delete any files in "dest-dir" not found in "src-dir" | rsync -av --delete src-dir remote-user@remote-host:dest-dir |
search for all the files which have not been modified in the last 6 months in current folder and display the disk usage of them | find . -mtime +180 -exec du -sh {} \; |
Locate all *.txt files in the current directory tree | find . -name '*.txt |
Find files with SGID and SUID permssions set in the file system | find / \ -ls |
Print reverse lookup for IP address 72.51.34.34 | dig -x 72.51.34.34 |
force delete all the regular files with the name "test.txt" | find /home -type f -name test.txt -exec rm -f {} \ |
Find all files/directories named 'document' in maximum 4 levels down the '/usr' directory | find /usr -maxdepth 4 -name document -print |
list all CSS files under the current directory | find . -type f -name "*.css" |
create an archive excluding files matching patterns listed in /path/to/exclude.txt | tar -czf backup.tar.gz -X /path/to/exclude.txt /path/to/backup |
List detailed information about all Jar files in the current directory tree | find . -iname "*.jar" | xargs zipinfo |
Delete all files in the /myDir directory tree that were last modfied more than 7 days ago | find /myDir -mindepth 1 -mtime +7 -delete |
Find all files/directories containing 'foo' in their names under current directory tree | find . -name '*foo*' |
find all the files that have been modified exactly 1 day ago | find -mtime 1 |
Count the number of times that a single "-----------\n" separated record contains both "A=2" and "dummy=2" and the number of records that do not have "dummy=2" in compressed file "file.gz" | zcat file.gz | awk -v RS="-----------\n" '/A=2[ ,\n]/ && /dummy=2[ ,\n]/{count++} !/dummy=2[ ,\n]/{other++} END{print "Final counter value=",count, "; other=", other}' |
delete all the files in the current folder which have been modified in the last 14*24 hours | find . -mtime -14 -print|xargs -i rm \; |
List all files in entire file system that are newer than the file $newerthan and older than the file $olderthan in regards of modification time | find / -type f -name "*" -newermt "$newerthan" ! -newermt "$olderthan" -ls |
Save the user name in all capitals of the current user to variable "v" | v=$(whoami | awk '{print toupper($0)}') |
Wrap each line in "file" to fit in 80 characters and count the number of lines | fold file | wc -l |
display all text files in the current folder | find . -type f -name "*.txt" |
Generates temporary file in a '/dev/shm' folder and saves path to it in a 'tFile' variable. | tFile=$(mktemp --tmpdir=/dev/shm) |
display all the files in the current folder | find . | xargs echo |
find all the files in the file system which have not been modified in the last 100*24 hours | find / -mtime +100 -print |
Run an awk program on every TXT file found in the current directory tree | find . -name "*.txt" -print -exec awk '$9 != "" && n < 10 {print; n++}' {} \; |
Count the number of all directories under current directory non-recursively | find . -mindepth 1 -maxdepth 1 -type d | wc -l |
Find all *.sql files in maximum 1 level down the current directory, process it with sed and then send the output to a mysql command | find -maxdepth 1 -name '*.sql' -exec sed -e 's/ , );/1,1);/g' '{}' | mysql -D ootp |
List and sort all leaf directories (directories which don't contain any sub-directory) under current directory | find . -type d | sort | awk '$0 !~ last "/" {print last} {last=$0} END {print last}' |
Find all regular files under current directory tree that match the regex 'tgt/etc/*' in their paths | find . -type f -name \* | grep "tgt/etc/*" |
Find files on the system accessed during the last 24 hours but not within the last hour | find / -atime -1 -amin +60 |
Display who is logged on and what they are doing | w |
read all history lines not already read from the history file | history -n |
Find all directories named "D" in the "A" directory tree | find A -type d -name 'D' |
List all *.txt files/directories under current directory ensuring white space safety | find . -name '*.txt' -print0|xargs -0 -n 1 echo |
Find files under /tmp that are larger than 10KB and smaller than 20KB | find /tmp -size +10k -size -20k |
Prints days since epoch | echo `date +%s`/86400 | bc |
List all *.txt files/directories under /etc | ls -l $(find /etc -name "*.txt" ) |
Find all files under /path/to/dir and change their permission to 644 | find /path/to/dir -type f -exec chmod 644 {} + |
Write "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" to standard output and append to "/etc/apt/sources.list.d/10gen.list" as root | sudo echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | sudo tee -a /etc/apt/sources.list.d/10gen.list |
Synchronize "dir_a" and "dir_b" to contain the latest files in both directories | rsync -urv --progress dir_a dir_b && rsync -urv --progress dir_b dir_a |
Read standard input until a null character is found and save the result in variable "f2" | read -r -d $'\0' f2 |
Find all files on smbfs mounts and print its information and file type | find $ -mount -type f -ls -execdir file {} \; |
Find all empty files under /tmp | find /tmp -type f -empty |
Execute "bash -c 'python -m unittest discover |& pyrg'" in a shell with color support every second | watch -n 1 --color --exec bash -c 'python -m unittest discover |& pyrg' |
Make directory "aaa" | mkdir aaa |
Follow symbolic links for the full path of "lshw" | readlink -f $(which lshw) |
List all *jsp and *java regular files found in the current directory tree | find . \( -name '*jsp' -o -name '*java' \) -type f -ls |
Reports count of characters in the value of ${FOO_NO_LEAD_SPACE} variable as follows: "length==<counted number of characters>" | echo -e "length==$" |
Print the filenames taken by the glob pattern * with null character as the delimiter | find * -maxdepth 0 -type d -print0 |
Find all files/directories under current directory tree that contain '1' or 'k' in their names | find . -name "*[1k]*" |
Find all files that belong to user root | find / -user root |
Check if RBENV is defined in the current tmux session environment | tmux show-environment | grep RBENV |
Do a dry run of renaming file extension '.andnav' to '.tile' for all files/directories under current directory tree | find . -name "*.andnav" | rename -vn "s/\.andnav$/.tile/" |
Recursively removes all empty folders under current path, printing info message on each operation, and suppressing error messages if folder is not empty. | find -type d -empty -exec rmdir -vp --ignore-fail-on-non-empty {} + |
Always answer "no" to any prompt from "<command>" | yes no | <command> |
Print each unique entry in "ip_addresses" followed by a count | cat ip_addresses | sort | uniq -c | sort -nr | awk '{print $2 " " $1}' |
Recursively find files in the current directory with a modification time more than 7 days ago, save the filenames to "compressedP.list", and compress each file in parallel | find . -type f -mtime +7 | tee compressedP.list | parallel compress |
Check if directory $some_dir is empty | find "`echo "$some_dir"`" -maxdepth 0 -empty |
Edit current user's cron job list with editor specified by EDITOR environment variable, or default /usr/bin/editor if EDITOR is not set. | crontab -e |
Find all *.jpg files under current directory and print only unique names | find . -name \*.jpg -exec basename {} \; | uniq -u |
Print the contents of "Little_Commas.TXT" | cat Little_Commas.TXT |
Find all PHP files in the current directory recursively | find . -name \*.php -type f |
Find blabla* files under current directory | find . -depth -name "blabla*" -type f | xargs rm -f |
Find the largest files in a particular location | find /home/tecmint/Downloads/ -type f -printf "%s %p\n" | sort -rn | head -n 5 |
Move all files that contain "Subject: \[SPAM\]" to "DIR" | grep -l 'Subject: \[SPAM\]' | xargs -I '{}' mv '{}' DIR |
Print 'cp' commands that would copy a file xyz.c to all the files with '.c' extension present in the ./C directory and below | find ./C -name "*.c" | xargs -n1 echo cp xyz.c |
Rename all .html files to .txt in a portable way without requiring the "rename" perl script. | for file in *.html; do mv "$file" "${file%.html}.txt"; done |
Saves space separated content of $RAW_LOG_DIR in FILES variable | FILES=`cat $RAW_LOG_DIR | xargs -r` |
create directory testExpress | mkdir testExpress |
Display infinite scroll of random ASCII art | yes 'printf \\u$[2571+RANDOM%2]'|bash |
Find all files under /home/myfolder that match the regex 'abc.*def.*ghi' in their contents | find /home/myfolder -type f -print0 | xargs -0 grep -l -E 'abc.*def.*ghi' |
Display "infile" as printable characters or backslash escapes | cat infile | od -c |
Find all symbolic links in the current directory tree | find -type l |
Recursively change the owner to "user" and group to "www-data" of "yourprojectfoldername" | chown -R user:www-data yourprojectfoldername |
remove all the pdf files in the current folder and do not delete those in the sub folders | find . -name "*.pdf" -maxdepth 1 -print0 | xargs -0 rm |
display all text files in current folder | find . -name "*.txt" |
Find all directories named "D" in the current directory tree | find ./ -type d -name 'D' |
Remove all files in the $backup_path directory recursively that were last modified more than 30 days ago | find $backup_path/* -mtime +30 -exec rm {} \; |
Find all text files in the home directory | find ~/ -name '*.txt' |
Delete all lines matching "pattern" in "filename" | sed -i '/pattern/d' filename |
find all symbolic links in the current folder | find -type l |
Report available space on the file system containing /tmp in kilobytes. | df -k /tmp | tail -1 | tr -s ' ' | cut -d' ' -f4 |
change owner of the file process to user root | sudo chown root process |
Find all files/directories in current directory and execute multiple commands for each file/directory | find . -exec bash -c 'cmd1; cmd2' filedumper {} \; |
run script /PATH/TO/MY_APP as user USER_FOOBAR in background | su - USER_FOOBAR -c /PATH/TO/MY_APP & |
Remove sequence like '\xEF\xBB\xBF' from first string of every file in a current folder and subfolders, creating backup file with .bak extension for every changed file, and removing backup on success. | find . -type f -exec sed '1s/^\xEF\xBB\xBF//' -i.bak {} \; -exec rm {}.bak \; |
Print the output of history without line numbers | history | sed 's/^[ ]*[0-9]\+[ ]*//' |
Create directories "/tmp/x/y/z/" on remote host before copying "$source" to "user@remote:/tmp/x/y/z/" | rsync -a --rsync-path="mkdir -p /tmp/x/y/z/ && rsync" $source user@remote:/tmp/x/y/z/ |
Find files newer than main.css in ~/src | find ~/src -newer main.css |
Compute the mean average of the word count of *.txt files smaller than 2000 words in the home directory | find ~/Journalism -name '*.txt' -print0 | xargs -0 wc -w | awk '$1 < 2000 {v += $1; c++} END {print v/c}' |
find all files in the current folder that are modified exactly 1 minute ago | find -mmin 1 -print |
Remove all directories called "test" from the /path/to/dir directory tree | find /path/to/dir -name "test" -type d -delete |
find the file arrow.jpg in the entire file system | find / -name arrow.jpg |
Search for files/directories with the case insensitive pattern anaconda.* in var/log directory and create an archive (file.tar) of all the files found | find var/log/ -iname "anaconda.*" -exec tar -rvf file.tar {} \; |
Make directories to "$2" as needed | mkdir -p $2 |
Print the full path of a file under the current working directory with inode number specified on standard input | xargs -n 1 -I '{}' find "$(pwd)" -type f -inum '{}' -print |
Send SIGTERM signal to any process which 'ps' lists as "python csp_build.py" | ps aux | awk '$11" "$12 == "python csp_build.py" { system }' |
List all files under the current working directory last modified less than a day ago | find `pwd` -mtime -1 -type f -print |
find all the files that have been modified in the last 1 day | find . -type f -daystart -mtime -1 |
Print the icmp sequence number and ping time of each request to "127.0.0.1" | ping -c 2 -n 127.0.0.1 | awk -F'[ =]' -v OFS='\t' 'NR>1 { print $6, $10 }' |
Add "Line of text here" on top of each *.py files under current directory | find . -name \*.py | xargs sed -i '1a Line of text here' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.