nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
display all the jpg files in the current folder and do not search in sub directories | find . -maxdepth 1 -mindepth 1 -iname '*.jpg' -type f |
find all files in the current folder that have a single letter in their name and have not been modified today | find . -name \? -mtime +0 |
Immediately display unique entries from access.log | tail -f access.log | stdbuf -oL cut -d ' ' -f1 | uniq |
display all the files in the user folder which have been modified after the files /tmp/stamp$$ | find /usr -newer /tmp/stamp$$ |
Get a list of directories owned by group ID 100 | find / -type d -gid 100 |
Make a new directory "new-dir" in every directory in the current working directory non-recursively | find . -maxdepth 1 -type d | xargs -I "{x}" mkdir "{x}"/new-dir |
redirect output inside screen session | screen /bin/bash -c 'java Foo > foo.txt' |
Kill the processes of user `myuser' that have been working more than 7 days | find /proc -user myuser -maxdepth 1 -type d -mtime +7 -exec basename {} \; | xargs kill -9 |
Find all directories recursively starting from / and count them | find / -type d | wc -l |
display all files in the current folder which end with extension "myfile" followed by two digits | find . -regex '.*myfile[0-9][0-9]?' |
Create a new RSA key for ssh with no passphrase, store it in ~/.ssh/id_rsa without prompting to overwrite if this file exists, and minimize output from ssh-keygen. | echo -e 'y\n'|ssh-keygen -q -t rsa -N "" -f ~/.ssh/id_rsa |
display all normal/regular files in current folder in sorted order | find . -type f print0 | sort -r |
Merge already sorted files in the current directory starting with "_tmp" and write the output to "data.tsv.sorted" | sort -m _tmp* -o data.tsv.sorted |
Create symlinks to all /home/folder1/*.txt files and 'folder1_' directory with the same name in a target directory named '+' | find /home/folder1/*.txt -type f -exec ln -s {} "folder1_" +\; |
Find all 2*.data files/directories under jcho directory | find jcho -name 2*.data |
find all the empty in the current folder do not search in sub directories | find . -maxdepth 1 -type d -empty |
Clear the in-memory history | history -c |
Find all *foo* files/directories under current directory and copy them to /your/dest | find . -name "*foo*" | sed -e "s/'/\\\'/g" -e 's/"/\\"/g' -e 's/ /\\ /g' | xargs cp /your/dest |
Remove all files with a txt extension under current directory | find . -type f -name "*.txt" | xargs -I {} ksh -c "echo deleting {}; rm {}" |
Recursively copy directories "A" and "D" to directory "/path/to/target/directory" on host "anotherhost", connecting as ssh user matching current user on local host, via default TCP port for ssh (22). | scp -r A D anotherhost:/path/to/target/directory |
Display inputfile all on one line | awk 1 ORS=' ' file |
Rename .jpg files to .jpeg in all level 2 subdirectories of the current directory | find -maxdepth 3 -mindepth 3 -type f -iname '*.jpg' -exec rename -n 's/jpg$/jpeg/i' {} + |
Remount "/dev/stl12" on "/system" as read and write | mount -o rw,remount /dev/stl12 /system |
tar all the regular java files to myfile.tar | find . -type f -name "*.java" | xargs tar cvf myfile.tar |
Counts total lines in PHP and JS files. | find . -name '*.js' -or -name '*.php' | xargs wc -l | grep 'total' | awk '{ SUM += $1; print $1} END { print "Total text lines in PHP and JS",SUM }' |
Find recursively the latest modified .zip file in the current directory | find . -name "*zip" -type f | xargs ls -ltr | tail -1 |
Report total size of the root filesystem disk usage in powers of 1000. | df -H --total / |
Return 0 if at least one "abc" file in the current directory tree contains text "xyz" | find . -name 'abc' -type f -exec grep -q xyz {} + |
Split "mybigfile.txt" into files of at most 200000 lines each | split -l 200000 mybigfile.txt |
Remove files that are greater than 1MB in size under current directory | find . -type f -size +1M -exec rm {} + |
find all directories with the name "lib64" in the usr folder and replace space with ':' | find /usr -name lib64 -type d|paste -s -d: |
search for all the files in current folder and display all the file names separated by space | find . | awk '{printf "%s ", $0}' |
Find all directories under '/nas' directory tree | find /nas -type d |
Login to "user@host" with key "keyFile" and execute "./script arg1 arg2 > output.txt 2>&1" in the background | ssh -i keyFile user@host bash -c "\"nohup ./script arg1 arg2 > output.txt 2>&1 &\"" |
Print info about all mounted file systems, and grand total statistic about available and used space | df --total |
Find all *.c files under and below the current directory that contain "wait_event_interruptible" | find . -name \*.c -exec grep wait_event_interruptible {} /dev/null \; |
Find symlinks under and below the "test" directory and replace them with the content of the linked files | find test -type l -exec cp {} {}.tmp$$ \; -exec mv {}.tmp$$ {} \; |
recursively look for files ending in either .py or .py.server | find . \ |
Search the .java files from the /Applications/ directory tree for TODO lines | find /Applications/ -name "*.java" -exec grep -i TODO {} + |
create directory new_dir | mkdir new_dir |
Send each byte in "/home/cscape/Desktop/table.sql" to awk | fold -1 /home/cscape/Desktop/table.sql | awk '{print $0}' |
display all the mp4 and flv files in a folder along with their timestamps in the sorted order of time | find /storage -type f \ -printf '%T@ %p\0' | sort -zn) |
Print "new.txt" with line numbers prepended and lines 3 and 4 deleted | cat new.txt | nl |sed "3d;4d" |
run command "R -e \"install.packages\"" as user root with a full login simulation | sudo su - -c "R -e \"install.packages\"" |
Report file system containing the current directory disk usage in kilobytes. | df -k . |
List the unique parent directories of all .class files found in the entire filesystem | find / -name *.class -printf '%h\n' | sort --unique |
Print the names and sizes of regular files residing in the "tmp" directory tree | find tmp -type f -printf "%s %p\n" | awk '{sub(/^[^ ]+/,sprintf("f %10d",$1))}1' |
Assign permissions 755 to directories in the current directory tree | find . -type d -print0 | xargs -0 chmod 755 |
Create an empty file with a carriage return character in its name. | touch $'Icon\r' |
remove all the files in the present directory which have space in their name. | find . -name "* *" -exec rm -f {} \; |
find all files in the current folder which are bigger than 10bytes | find . — size +10 -print |
Set variable 'path' to name of current directory converted to lowercase. | path=$(basename $ | awk '{print tolower}') |
Make directory "testExpress" | mkdir testExpress |
Print 'Empty dir' if $some_dir is empty | if find "`echo "$some_dir"`" -maxdepth 0 -empty | read v; then echo "Empty dir"; fi |
Split the first 100 lines of "datafile" into files with at most 1700 bytes each preserving lines | sed 100q datafile | split -C 1700 - |
Find all regular files in the current directory tree and search them for "example" | find -type f -print0 | xargs -r0 grep -F 'example' |
Find recursively all empty directories in the current directory | find -type d -empty |
Move all *.mp4 files from directory /foo/bar and its subdirectories to /some/path | find /foo/bar -name '*.mp4' -print0 | xargs -0 mv -t /some/path {} |
List all *.txt files under current directory that match 'foo=' in their file information | find . -name "*.txt" -type f -print | xargs file | grep "foo=" | cut -d: -f1 |
Find all files of the user with UID=1000 | find -uid 1000 |
Find a used disk space of a target directory and files inside of it | du -h your_directory |
Remove all directories called "test" from the current directory tree | find . -name test -type d -exec rm -r {} \; |
Find files/directories writable by group and others under the /path directory | find /path -perm -g+w,o+w |
Rename all files in the current directory starting with "fgh" to start with "jkl" | for f in fgh*; do mv "$f" $; done |
Find all *.c files under /home | find /home -name "*.c" |
Print and recursively remove the alphabetically last directory in the current directory | find -mindepth 1 -maxdepth 1 -type d | cut -c 3- | sort -k1n | tail -n 1 | xargs -r echo rm -r |
Find all *.txt files/directories under current directory and execute the python script hello.py for each of them with the file path as an argument to the script | find . -name "*.txt" | python hello.py |
Modify interval to 0.1 seconds for the watch command | watch -n 0.1 |
Print file information of command "studio" | which studio | xargs ls -l |
Make a directory structure same as the current directory tree under /tmp/tar_root directory | for i in `find . -type d`; do mkdir -p /tmp/tar_root/`echo $i|sed 's/\.\///'`; done |
Move all *$lower1* files/directories under current directory to paths formed by replacing the match of $lower1 with $lower2 in their paths | find . -name "*$lower1*" -exec bash -c 'mv "$1" "${1/$2/$3}"' -- {} $lower1 $lower2 \; |
Copy specific sub-directories "company1/" and "company1/unique_folder1" from "[email protected]:/path/to/old/data/" to "/path/to/new/data" via ssh | rsync -avzn --list-only --include 'company1/' --include 'company1/unique_folder1/***' --exclude '*' -e ssh [email protected]:/path/to/old/data/ /path/to/new/data |
Find all files/directories that are owned by user 'dave' under current user's home directory tree | find ~ -user dave -print |
Find all files under current directory, calculate their md5sum and print each of the hash and file name to filename-hash.md5 files | find . -type f | while read f; do g=`md5sum $f | awk '{print $1}'`; echo "$g $f"> $f-$g.md5; done |
Generates default-formatted file name of temporary file in a /dev/mapper folder, and saves path to it in a variable 'MAPPER'. | MAPPER=$ |
search in the current folder for the file with the name "test" | find . -name test |
Save $line line in history | history -s "$line" |
find all the text files in the home folder | find ~ -name "*.txt" — print |
Copy "./export" recursively to "/path/to/webroot" preserving permissions | rsync -pr ./export /path/to/webroot |
Unzip and extract "*\ [^ =]\+=.*" from "input.gz" | zcat input.gz | sed -n 's/.*\ [^ =]\+=.*/\1/p' |
find file named foo.txt under current directory. | find . -name foo.txt |
Find all files/directories in current directory and execute multiple ANDed commands for each file | find . -exec cmd1 \; -exec cmd2 \; |
Find all directories in maximum 2 levels down the /tmp directory | find /tmp -maxdepth 2 -mindepth 1 -type d |
Find all files under current directory | find -type f |
display all the empty files in the folder /opt | find /opt -type f -empty |
find setuid files and directories writing the details to /root/suid.txt , and find large files writing the details to /root/big.txt, traversing the filesystem just once | find / \ , \ \ |
Execute 'tput setaf 1; echo foo' with color support every 2 seconds | watch --color 'tput setaf 1; echo foo' |
search for the word text in all the python files in the current folder | find . -iname '*py' -exec grep "text" {} \; |
prints the names of all files in the directory tree rooted in /usr/src whose name ends with ‘.c’ and that are larger than 100 Kilobytes. | find /usr/src -name '*.c' -size +100k -print |
Open gcc info manual and select "option index" menu entry. | info gcc "option index" |
Find all .txt files under the current directory and below | find -name \*.txt |
Remove all files with the .c extension in the current directory tree | find . -name "*.c" | xargs rm -rf |
Format and print the time string @133986838 according to the default time format | date --date @120024000 |
Find all 400 permission files under /data directory with null character as the delimiter | find /data -type f -perm 400 -print0 |
Verbosely compresses all files on second and third depth level keeping original files in place. | bzip2 -kv */* |
find files in current directory that names are game | find . -name game |
Print a list of all filepattern-*2009* files/directories under data/ to filesOfInterest.txt file | find data/ -name filepattern-*2009* -print > filesOfInterest.txt |
copy a files from one folder to all the folder in the /raid which have an extension local_sd_customize. | find /raid -type d -name ".local_sd_customize" -ok cp /raid/04d/MCAD-apps/I_Custom/SD_custom/site_sd_customize/user_filer_project_dirs {} \; |
Find all files/directories in all paths expanded by the glob pattern * | find * |
Delete all the 'test' directories from all directories under maximum 1 level down the current directory that contain directories named 'test' and 'live' | find -maxdepth 1 -type d -exec sh -c "cd {} && [ -d test ] && [ -d live ] && rm -rvf test " {} \; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.