nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
display only the file names of all the files which end with ".deb" | find . -name '*.deb' -printf "%f\n" |
Find all files in directory tree /tmp/foo and pass them as arguments to script /tmp/echoargs | find /tmp/foo -exec /tmp/echoargs {} + |
Find all directories under the current directory that is on the same filesystem, execute "/tmp/count_em_$$" with the directory as an argument, sort the result numerically from least value to greatest value | find . -mount -type d -print0 | xargs -0 -n1 /tmp/count_em_$$ | sort -n |
Find all .java files under current directory | find . -print | grep '\.java' |
Lists all subdirectories in current directory with a trailing slash | ls -d ./*/ ### more reliable BSD ls |
Search the file system for regular files whose pathnames are shorter than 25 characters | find / -type f|awk -F'/' '{print $NF}'| awk 'length($0) < 25' |
all .jpg or .png images modified in the past week | find . -mtime -7 \ |
Print the full path of a 'file.txt' file in the current folder. | ls "`pwd`/file.txt" |
Print space separated list of numbers from "$start" to "$end" | seq -s' ' $start $end |
reverse input with comma deliminators | echo "a,b,c" | tr '\n' ',' | tac -s "," | sed 's/,$/\n/' |
Find all .c, .h files in the current directory tree and search them for string "expr" | find . -name '*.[ch]' | xargs grep -E 'expr' |
find files which full path name is /tmp/foo/bar under foo directory and print | find foo -path /tmp/foo/bar -print |
Search the .VER files from the current directory tree for string "Test_Version=' | find . -name "*.VER" -exec grep 'Test_Version=' '{}' ';' -print; |
Find recursively all empty directories in the current directory | find -type d -empty |
Find directories owned by user news with permissions 775 | find / -user news -type d -perm 775 -print |
Find all CDC* files under current directory that were accessed less than 1 day ago and delete the first and last lines from those files | find . -type f -name "CDC*" -ctime -1 -exec sed -i'' -e '1d' -e '$d' '{}' \; |
change the permissions of all the directories in the current folder | chmod 751 `find ./ -type d -print` |
delete all the files in the file system which belong to the user edwarda after user confirmation | find / -user edwarda -ok rm "{}" \; |
find all the reglar files which ahve been changed in the last 5 minutes and do not search in the sub directories. | find /home/pankaj -maxdepth 1 -cmin -5 -type f |
Find the oldest *.sql file under current directory | find . -name \*.sql | xargs \ls -1rc | tail -7 | head -1 |
Find all files under current directory whose file type description contains "image", display only path to each file. | find . -type f -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}' |
Find all files more than 700 megabytes | find / -size +700M |
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' {} + |
find all the error, access, ssl_engine and rewrite logs which are bigger than 300MB and are less then 5GB in the folder /opt | find /opt \( -name error_log -o -name 'access_log' -o -name 'ssl_engine_log' -o -name 'rewrite_log' -o -name 'catalina.out' \) -size +300000k -a -size -5000000k |
Archive "/home/user1" to "wobgalaxy02:/home/user1" excluding hidden files | rsync -av /home/user1 wobgalaxy02:/home/user1 |
Find all TXT files on the system and copy them to /tmp/txt | find / -iname '*.txt' | xargs --replace=@ cp @ /tmp/txt |
display table of files with their name, owner, and size in bytes. | find . -printf 'Name: %f Owner: %u %s bytes\n' |
Find all regular files matching the name pattern '*.?htm*' under '/srv/www' and '/var/html' directory tree | find /srv/www /var/html -name "*.?htm*" -type f |
Print the current directory | find -prune |
Find all executable files under current directory and reverse sort them | find . -perm -111 -type f | sort -r |
Sets shell option 'globstar'. | shopt -s globstar |
Find all directories under current directory tree that match the case insensitive regex '^\./course\([0-9]\.\)*[0-9]$' in their paths | find . -type d -iregex '^\./course\([0-9]\.\)*[0-9]$' |
Print the directory name of the physical current working directory | dirname `pwd -P` |
Search for first match of the case insensitive regex 're' in all *.coffee files under current directory and print the file paths along with the matches | find . -print0 -name '*.coffee'|xargs -0 grep -m1 -ri 're' |
Prints a random line from $FILE | sort --random-sort $FILE | head -n 1 |
Display current running kernel's compile-time config file. | cat /boot/config-`uname -r` |
find directory which case-insensitive name is too in currect directory | find . -iname foo -type d |
Create a report of the contents of a USB drive mounted at find /path/to/drive | find /path/to/drive -type f -exec file -b '{}' \; -printf '%s\n' | awk -F , 'NR%2 {i=$1} NR%2==0 {a[i]+=$1} END {for (i in a) printf("%12u %s\n",a[i],i)}' | sort -nr |
Find *.c and *.h files under the current directory tree skipping hidden directories and files | find . \( -path '*/.*' -prune -o ! -name '.*' \) -a -name '*.[ch]' |
Find recursively all files changed within the last 5 minutes starting from directory b | find b -cmin -5 |
Find regular non-hidden files containing 'some text' in their names | find . -not -path '*/\.*' -type f -name '*some text*' |
Dispaly the latest version of Joomla in various folders | find /home/*/public_html/ -type f \ -print0 -exec perl -e 'while { $release = $1 if m/ \$RELEASE\s+= ..;/; $dev = $1 if m/ \$DEV_LEVEL\s+= ..;/; } print qq;' {} \; |
Search for "ifconfig" in the output of "history" and print 5 lines that precede and follow | history | grep -C 5 ifconfig |
Find all file.ext files/directories under /home/kibab directory and print . for each of them | find /home/kibab -name file.ext -exec echo . ';' |
Remove junk files modified more than 31 days ago recursively | find /path/to/junk/files -type f -mtime +31 -exec rm -f {} \; |
Synchronize via ssh "user@source-server:/somedirA/" to "somedirB/" with compressed data during transmission and display progress | rsync -avz -e ssh --progress user@source-server:/somedirA/ somedirB/ |
Find all symbolic links containg 'vim' in their names under '/usr/bin' directory tree | find /usr/bin -name '*vim*' -type l |
Print "new.txt" with line numbers prepended | cat new.txt | nl |
Find all *weservice* files under current directory and restart the services provided by them | find -iname '*weservice*'|xargs -I {} service {} restart |
display all the regular files in the current folder that are modified after the file "file.log" | find . -type f -newer file.log |
Create 5 empty .txt files | echo "a.txt b.txt c.txt d.txt z.txt" | xargs touch |
List files in the current directory | find . \( ! -name . -prune \) |
Find all files under the current directory that are not the same file as "/home/nez/file.txt" | find . -maxdepth 1 -not -samefile /home/nez/file.txt |
Search the current directory tree for files that are less than 50kb | find . -size -50k |
Insert "|" every 30 characters in file "longline" | fold -w30 longline | tr '\n' '|' | sed 's/|$/\n/' |
Pass all the files from the current directory tree as arguments to a single 'echo' command | find . -exec echo {} + |
Display a character dump of "oldfile" | od -c oldfile |
Set trace prompt to print seconds, nnoseconds, script name, and line number | PS4='+$(date "+%s:%N") %N:%i> ' |
find files in /dir/path/look/up directory that names are dir-name-here | find /dir/path/look/up -name "dir-name-here" |
Find all .gz archives in the current directory tree and check if they are valid | find . -name *.gz -exec gunzip '{}' \; |
find files which modification time is 7 days ago | find . -mtime -7 |
List all regular files in the current directory tree modified within the last 24 hours | find . -mtime 0 -type f -ls |
Print the character representations of 65 to 90 | seq 65 90 | awk '{printf}' |
Find files with a question mark in their names and save the output as a file | find . -name \*\\?\* > output.txt |
find all the text files in the current folder | find . — name "*.txt" — print |
Remount "/dev/stl12" on "/system" as read and write | mount -o rw,remount /dev/stl12 /system |
List all files in entire file system owned by the user wnj and are newer than the file ttt | find / -newer ttt -user wnj -print |
Compress in parallel regular files in the current directory tree that were last modified more than 7 days ago | find . -type f -mtime +7 | tee compressedP.list | parallel compress |
Calculte and output amount of CPU load taken by all processes belonging to user 'abc'. | top -b -n 1 -u abc | awk 'NR>7 { sum += $9; } END { print sum; }' |
Locates bzip2 command in a system. | which bzip2 |
Find files belonging to the given owner | find /path/to/search -user owner |
List all regular file owned by root with permissions 4000 | find / -type f -user root -perm -4000 -exec ls -l {} \; |
Rename all directories under current directory by replacing all occurrences of 'Foo' (case insensitive) with 'Bar' in their names | find . -type d -iname '*foo*' -depth -exec rename 's@Foo@Bar@gi' {} + |
Format output of 'file' content to columns with wide not less than 80 pixels | cat file | column -c 80 |
find all the files within your home folder accessed more than 100 days ago | find ~ -atime 100 |
Split "INPUT_FILE_NAME" into files of at most 500 MiB each with a numeric suffix of length 4 and prefix "input.part." | split -b 500M -d -a 4 INPUT_FILE_NAME input.part. |
Search directory tree `MyApp.app' for directories whose name is 'Headers' and delete them | find MyApp.app -name Headers -type d -delete |
Convert all characters in "$a" to upper case and save to variable "b" | b=`echo "$a" | sed 's/./\U&/g'` |
Set variable "b" to the first word of "a" converted to uppercase. | b=`echo "$a" | awk '{ print toupper }'` |
Print only alphanumeric values from "/dev/urandom" | cat /dev/urandom | tr -dc 'a-zA-Z0-9' |
find all the xml files in a directory and pass it as an argument to a jar | find /dump -type f -name '*.xml' | parallel -j8 java -jar ProcessFile.jar {} |
Create a copy of the current working directory structure in the usr/project directory, | find . -type d -print|sed 's@^@/usr/project/@'|xargs mkdir |
Delete all files/directories named test under maximum 2 level down the current directory | find . -maxdepth 2 -name "test" -exec rm -rf {} \; |
Force tty allocation and execute "./script.py" on host "foo" | ssh -tt foo ./script.py |
List all files in a current folder, separating names with semicolon | ls -1b | tr '\n' ';' |
change user and group of the file bin to user and group root:wheel | sudo chown root:wheel bin |
Create directory dir2 | mkdir dir2 |
find all empty files in /tmp directory . | find /tmp -type f -empty |
Find all files/directories in entire file system for which owner has read/write/execute permissions, or the group has at least execute permission, or others have at least execute permission | find / -perm /711 |
Find all CSS files that do something with HTML ID #content | find . -name "*.css" -exec grep -l "#content" {} \; |
search for the ".git" folder in the current folder and run the git pull request | find . -name .git -type d -execdir git pull -v ';' |
display a long listing of all the temp files whose size is 0 bytes and which have not been accessed in the last 10 days | find /tmp -size 0 -atime +10 -exec ls -l {} \; > /tmp/checkold.txt |
Remove trailing whitespaces from all regular non-hidden files in the current directory tree | find . -type f -name '*' -exec sed --in-place 's/[[:space:]]\+$//' {} \+ |
For each line of colon-separated information in files 'empsal' and 'empname' whose first field matches in both files, output: first field of empname, second field of empname, fourth field of empname, and third field of empsal. | join -j 1 -t : -o 2.1,2.2,2.4,1.3 <(sort empsal) <(sort empname) |
print value of the variable $PROJ_PATH of the kenneth system user environment | su -l kenneth -c 'echo $PROJ_PATH' |
convert all text files in the current folder from dos to unix format | find . -name *.txt | xargs dos2unix |
Compress each file in all directories matching pattern "*.1" | find *.1 -exec tar czf '{}.tgz' '{}' --remove-files \; |
find all the files in the entire file system excluding the folder proc, which do not belong to any user or any group | find / -path /proc -prune -o -nouser -o -nogroup |
Mount "tmpfs" filesystem to "/path/to/dir" | mount none -t tmpfs /path/to/dir |
Print information about all users who are logged in | who -la |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.