nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
force remove all the c files in the current folder, print0 is used to handle all files with new lines in their names or files with only spaces in their name | find . -name "*.c" -print0 | xargs -0 rm -rf |
Rewrite 'temp.txt' omitting any repeating lines | uniq temp.txt | perl -e 'undef $/; $_ = <>; open; print OUT;' |
removes last N lines from file.txt | head -$(gcalctool -s $-N) file.txt |
Search everywhere for hidden file `.profile' | find / -name .profile |
Find all empty files (zero byte files) in your home directory and its sub-directories. | find ~ -empty |
find all gif files in the file system | find / -name "*gif" -print |
Find files that are writable by both the “other” and the group | find plsql -type f -perm -220 -exec ls -l {} \; 2>/dev/null |
display list of all the hidden directories in the directory "/dir/to/search/" | find /dir/to/search/ -type d -iname ".*" -ls |
file1 and file2 contain lines of comma-separated information, for each line whose first field matches, and where 3rd field of file1 matches 2nd field of file2, 6th field of file1 matches 3rd field of file2, and 7th field of file1 matches 4th field of file2, output: fields 1, 2, 3, 4, 6, and 7 of file1. | join -t, file1 file2 | awk -F, 'BEGIN{OFS=","} {if print $1,$2,$3,$4,$6,$7}' |
List all cron jobs which contain "word". | crontab -l | egrep "word" |
Find *.html files in the current directory tree that were modified 7 days ago | find . -mtime 7 -name "*.html" -print |
Creates temporary folder like '/tmp/tardir-XXXXXX' with 6-letter suffix and saves its path in 'tmpdir' variable. | tmpdir=$ |
Print the commands that would execute "myfile" on all .ogv files from the current directory tree | find ./ -name *.ogv -exec echo myfile {} \; |
find all the files in the entire file system that have been modified between 50 to 100 days and display ten files | find / -mtime +50 -mtime -100 | head |
find all files in the file system having the name "filename" | find / -iname "filename" |
Prints name of temporary file but doesn`t create nothing. | mktemp -u |
Find all foo.mp4 files in the current directory tree and print the pathnames of their parent directories | find . -name foo.mp4 | sed 's|/[^/]*$||' |
Find all .gz archives in the current directory tree and check if they are valid | find . -name '*.gz' | xargs gunzip -vt |
Find all files/directories in maximum 1 level down the current directory which do not have only read permission for 'other' | find . -maxdepth 1 ! -perm -o=r |
display all the files in the file system which belong to no user | find / -nouser -print |
Search history for "part_of_the_command_i_still_remember_here" | history | grep 'part_of_the_command_i_still_remember_here' |
Exclude directory from find . command | find build -not \ -name \*.js |
Change permissions to 700 for directories at the current level and deeper | find . -mindepth 1 -type d | xargs chmod 700 |
Find the directories whose names contain "New Parts" at level 3 of the current directory tree and create symlinks to them in /cygdrive/c/Views | find -mindepth 3 -maxdepth 3 -type d -name "*New Parts*" -exec ln -s -t /cygdrive/c/Views {} \; |
display a long listing of all the files in the current folder | find . — type f -exec ls -1 {} \; |
Delete in the background all files in /var/tmp/stuff1 and below that have not been modified in over 90 days | find /var/tmp/stuff1 -mtime +90 -delete & |
Find all *.rb files/directories under current directory | find . -name \*.rb |
Change permissions to 644 for *.html files under /usr/local | find /usr/local -name "*.html" -type f -exec chmod 644 {} \; |
Records the number of occurences of 'needle' in the array 'haystack' into the variable 'inarray' | inarray=$(echo ${haystack[@]} | grep -o "needle" | wc -w) |
Find all files under /path/to/dir that were modified less than 7 days ago and show only first several lines of output | find /path/to/dir -type f -mtime -7 -print0 | xargs -0 ls -lt | head |
Join comma-separated data in file1 and file2, including extra non-matching information in both files. | join -t, -a1 -a2 < < |
List the directory paths of all file.ext files under present working directory | find $PWD -name "file.ext" -exec sh -c 'echo $' ';' |
find all the files that have been modified in the last 60 minutes | find -mmin -60 |
create a symbolic link named "www" to file "www1" | ln -s www1 www |
Remove regular files whose names match Perl regular expression '\w+-\d+x\d+\.\w+$' from the current directory tree | find -type f | grep -P '\w+-\d+x\d+\.\w+$' | sed -re 's/(\s)/\\\1/g' | xargs rm |
Move all files from the current directory to "targetdirectory" | find . ! -name . -prune -exec sh -c 'shift $1; mv "$@" targetdirectory/' 2 1 {} + |
Print the user name of the user running sudo | who -m | awk '{print $1}' |
Find all *shp* files/directories under current directory | find . -name '*shp*' |
keep only read access to all the files in a directory. | find /path/to/dir/ -type f ! -perm 0644 -print0 | xargs -0 chmod 644 |
Find the total size of *.jpg files within the directory tree ./photos/john_doe | find ./photos/john_doe -type f -name '*.jpg' -exec du -ch {} + | grep total$ |
Search the file system for regular files whose names are shorter than 25 characters | find / -type f -regextype posix-extended -regex '.*/.{1,24}$' |
Reads content of bzip2 compressed files and processes it with awk utility. | bzip2 -dc input1.vcf.bz2 input2.vcf.bz2 | awk 'FNR==NR { array[$1,$2]=$8; next } in array { print $0 ";" array[$1,$2] }' |
Find files/directories that isn't owned by the user 'apache' under /var/www | find /var/www ! -user apache -print0 | xargs -0 |
Print percentage of the space used on the $FILESYSTEM. | df -k $FILESYSTEM | tail -1 | awk '{print $5}' |
Report only total size of file systems in terabytes. | df -m | awk '{ SUM += $2} END { print SUM/1024/1024"TB" }' |
find all files & dircetiry in current directory which have .tmp extension and delete them . | find . -type f -name "*.tmp" -exec rm -rf {} \; |
Find all read only files in /home directory | find /home -type f -perm /u=r |
Read a line from standard input into variable "YESNO" ignoring backslash escapes and using the prompt "$ ? [y/N] " | read -r -p "$ ? [y/N] " YESNO |
Find all directories named "nasa" | find . -name nasa -type d |
Find all *.java files under current directory | find . -name "*.java" |
Find "$i" files under current directory and search for "$SrchStr" in those files | find . -name "$i" -type f -print | xargs egrep -n "$SrchStr" >/dev/null |
Find all regular non-hidden files in the current directory and its subdirectories | find . -not -path '*/\.*' -type f \( ! -iname ".*" \) |
remove all the files in the present directory which have special characters in their name and do not search in the sub directories of the current folder. | find . -name '*[+{;"\\=?~<>&*|$ ]*' -maxdepth 0 -exec rm -f '{}' \; |
Find recursively the latest modified file in the current directory | find . -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" " | sed 's/.*/"&"/' | xargs ls -l |
Run the find command with all shell positional arguments | `which find` "$@" -print0; |
Delete all the .c files present in the current directory and below | find . -name "*.c" | xargs rm -f |
find all the html files in current folder and replace some pattern in all these files | find -type f -name '*.htm' -printf '%P\0%f\0' | xargs -0 -n2 sh -c 'fil="${2/\.htm/}"; sed -i -e "s;<title>.*</title>;<title>$fil</title>;" $1' replace |
Find all *.txt files/directories under current directory and execute process_one for each of them | find . -name "*.txt -exec process_one {} ";" |
display all normal/regular files in the folder "pathfolder" | find pathfolder -type f |
find all the swap files (files ending with ~) in the current folder and delete them | find . -name "*~" -exec rm {} \; |
Find all directories named CVS, and deletes them and their contents. | find . -type d -name CVS -exec rm -r {} \; |
delete all files in $DIR that have not been accessed in at least 5 days | find "$DIR" -type f -atime +5 -exec rm {} \; |
Get the number of "use" statements in all PHP files, ordered | find . -type f -name "*.php" -exec grep --with-filename -c "^use " {} \; | sort -t ":" -k 2 -n -r |
find .bmp or .txt files | find /home/user/Desktop -name '*.bmp' -o -name '*.txt' |
Find regular files named "expression -or expression" under and below /dir/to/search/ | find /dir/to/search/ -type f -name 'expression -or expression' -print |
Display an amount of processes running with a certain name | ab=`ps -ef | grep -v grep | grep -wc processname` |
remove all the files in current folder which have the extension "DS_Store" | find . -name ".DS_Store" -exec rm {} \; |
Find .rmv files in the ./root directory recursively and copy them to directory /copy/to/here | find root -name '*.rmv' -type f -exec cp --parents "{}" /copy/to/here \; |
Print 'Since -printf is an action the implicit -print is not applied\n' for every file named 'file' found under current directory tree | find -name file -printf 'Since -printf is an action the implicit -print is not applied\n' |
show the sum of disk used by all the files that belong to the user "test1" in the entire file system | find / -user test1 -exec du -sm {} \;|awk '{s+=$1}END{print s}' |
extract 'archive.tar.gz' to /destination | gzip -dc archive.tar.gz | tar -xf - -C /destination |
List the largest file prefixed by its size in bytes of all files under the current directory | find . -type f -name '*.gz' -printf '%s %p\n'|sort -nr|head -n 1 |
Search the /home/sdt5z/tmp directory tree for files named "accepted_hits.bam" | find /home/sdt5z/tmp -name "accepted_hits.bam" |
Format the contents of "[file]" in a neat table | column -t [file] |
delete all the backup files in current directory | find . -name "*.bak" -delete |
Find all empty files in the current directory and delete them | find . -empty -maxdepth 1 -exec rm {} \; |
Display file.txt with lines numbered, and page interactively through the result. | less -N file.txt |
find all regex "./[a-f0-9\-]\{36\}\.jpg" files | find . -regex "./[a-f0-9\-]\{36\}\.jpg" |
Print the file paths and their sizes for all files under full_path_to_your_directory | find full_path_to_your_directory -type f -printf '%p %s\n' |
List all *jsp and *java regular files found in the current directory tree | find . \ -type f -ls |
Find all *.txt files/directories under current directory | find . -name "*.txt" |
Find all directories under /path/to/base/dir and change their permission to 755 | chmod 755 $ |
run ksh shell as user apache | su apache -s /bin/ksh |
find all files in the file system which are modified after the file /tmp/checkpoint | find / -newer /tmp/checkpoint |
send GET request to "http://testsite/api/" with header "Authorization: Token wef4fwef54te4t5teerdfgghrtgdg53" and format as json | curl -X GET -H "Authorization: Token wef4fwef54te4t5teerdfgghrtgdg53" http://testsite/api/ | python -mjson.tool |
Find CSS files omitting results containing "CVS" | find . \! -path "*CVS*" -type f -name "*.css" |
reverses order of lines in a.txt and saves them to b.txt | tac a.txt > b.txt |
Give rwx permissions to the user and group of the directory named "files" leaving others without any privileges | find . -type d -name files -exec chmod ug=rwx,o= '{}' \; |
Prints string "0 1 * * * /root/test.sh" to the terminal, and append it to file '/var/spool/cron/root' | echo "0 1 * * * /root/test.sh" | tee -a /var/spool/cron/root |
Find files named core in or below the directory /tmp and delete them. Note that this will work incorrectly if there are any filenames containing newlines, single or double quotes, or spaces. | find /tmp -name core -type f -print | xargs /bin/rm -f |
Create a gzip archive file ($tarFile) of all *.log files under $sourcePath | find $sourcePath -type f -name "*.log" -exec tar -uvf $tarFile {} \; |
Remove files from the file system that are owned by nobody, asking the user before each removal | find / -nouser -ok rm {} \; |
Replace all newlines from standard input except the last with spaces | sed 'x;G;1!h;s/\n/ /g;$!d' |
get year-month-day from date | date +%Y-%m-%d |
list regular file which file name is NOT end with '.html' in current directory in current directory | find . -type f -not -name "*.html" |
Find all files/directories with 664 permission under current directory tree | find -perm 664 |
Represent current date in RFC 3339 format with precision to seconds and save it to 'timestamp' variable | timestamp=`date --rfc-3339=seconds` |
List all regular files in entire file system | find / -type f -exec echo {} \; |
Find all symbolic links under current directory that are not hard links | find . -type f -links 1 -print |
Reversibly sorts content of the '${TMP}/${SCRIPT_NAME}.pid' file, comparing human readable numbers in file strings. | cat ${TMP}/${SCRIPT_NAME}.pid|sort -rh; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.