nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Search the current directory and all of its sub-directory for any PDF files being careful to prevent the shell from expanding anything in '*.pdf' before it'ss passed to find. | find . -name '*.pdf' -print |
set alias "git-root" for command 'cd $' | alias git-root='cd $' |
find all files beneath the current directory that begin with the letters 'Foo' and delete them. | find . -type f -name "Foo*" -exec rm {} \; |
Extract any line in "f1" or "f2" which does not appear in the other | comm -3 <(sort -un f1) <(sort -un f2) |
Creates temporary file in a TMPDIR folder with name like tmp.XXXXXXXXXX. | mktemp |
Find all files/directories with '.what_to_find' extension under current directory tree and show the list by excluding paths that contain 'excludeddir1' and 'excludeddir2' | find . -name '*.what_to_find' | grep -v exludeddir1 | grep -v excludeddir2 |
Print the contents of "my_script.py" | cat my_script.py |
Calculate the md5 sum of the file "filename" and print only the hash | md5sum filename |cut -f 1 -d " " |
Search for the extended regex expanded by"$MONTH\/$YEAR.*GET.*ad=$ADVERTISER HTTP\/1" in the decompressed contents of the /var/log/apache2/access*.gz files that are newer than ./tmpoldfile and older than ./tmpnewfile | find /var/log/apache2/access*.gz -type f -newer ./tmpoldfile ! -newer ./tmpnewfile \ | xargs zcat | grep -E "$MONTH\/$YEAR.*GET.*ad=$ADVERTISER HTTP\/1" -c |
find all the cpp files in the current folder | find . -iname '*.cpp' -print |
Save the full path of command "f" to variable "full_f" | full_f="$" |
Format the output of "printf ..." to fit in 80 characters per line | printf ... | fold -w 80 |
Remove all files under /home/user/Maildir/.SPAM/cur | find /home/user/Maildir/.SPAM/cur -type f -exec rm '{}' + |
Delete all regular files with inode number 314167125 under current directory tree | find . -type f -inum 314167125 -delete |
check the file type of all the regular/normal files in the current directory and save the output to the file /tmp/filetypes.log | find . -type f -exec file {} \; > /tmp/filetypes.log |
Find all *.ogg files/directories in entire file system | sudo find / -iname '*.ogg' |
Get the path of running Apache | ps -ef | grep apache |
Create new crontab set for user 'test' including $job and only jobs from current crontab of 'test' user that don`t contain $command | cat <(fgrep -i -v "$command" <) < | crontab -u test - |
display all the files in the file system which are smaller than 20 bytes | find / -size 20 |
Search directories /opt, /usr, /var for regular file foo | find /opt /usr /var -name foo -type f |
List all aliencoders.[0-9]+ files/directories under /home/jassi/ directory | find /home/jassi/ -name "aliencoders.[0-9]+" | xargs ls -lrt | awk print '$9' |
search for all the directories ending with ".mp3" in the file system and move them to the folder /mnt/mp3 | find / -iname "*.mp3" -type d -exec /bin/mv {} /mnt/mp3 \; |
Find recursively all regular files in the current directory whose names contain "." | find . -type f -a -name '*.*' |
Grab a gzipped text file from the web and display its decompressed content, interactively paging through the output. | curl -s 'http://archive.ubuntu.com/ubuntu/pool/universe/s/splint/splint_3.1.2.dfsg1-2.diff.gz' | gunzip -dc | less |
Print permissions of every directory in the current directory tree | tree -p -d |
Find files named 'core' in or below the directory /tmp and delete them | find /tmp -depth -name core -type f -delete |
Renames all *.html files in a 'folder' directory to *.txt files. | ls folder/*.html | xargs -I {} sh -c 'mv $1 folder/`basename $1 .html`.txt' - {} |
Split "2011.psv" into chunks of at most 50000000 lines each as input to "./filter.sh" | split -l 50000000 --filter=./filter.sh 2011.psv |
Find files in the /var/log folder which were modified modified 2 weeks ago | find /var/log/ -mtime +7 -mtime -8 |
Add "new." to the beginning of the name of "original.filename", renaming it to "new.original.filename". | rename 's/$/new.$1/' original.filename |
display all normal/regular files in current directory | find . -type f -print0 |
split all files in directory "posns " into pieces per 10000 lines | find posns -type f -exec split -l 10000 {} \; |
find all the regular/normal files in all the directories in the /some/dir and delete them | find /some/dir -type d -exec find {} -type f -delete \; |
Creates full path with parents, that matches to folder path extracted from $f variable. | mkdir -p -- "$" |
display the type of all the regular/normal files in the entire file system | find / -type f -print | xargs file |
Find all files that were last accessed more than 7 days ago under /home | find /home -atime +7 |
Find all directories in entire file system which are larger than 50KB | find / -type d -size +50k |
Delete all files with 128128 inode number under current directory tree | find . -inum 128128 | xargs rm |
Print continuous lines of 100 random characters either "." or " " | cat /dev/urandom | tr -dc '. ' | fold -w 100 |
Find all *.ogg (case insensitive) files/directories in entire file system | sudo find / -iname '*.ogg' |
Find all OGG files in the home directory that are at most 20 megabytes in size | find $HOME -iname '*.ogg' ! -size +20M |
display all the files ending with ".foo" including those that are in the directory ".snapshot", this is the wrong way of using prune. | find . \ -print |
Remove all .mpg files in the /home/luser directory tree | find /home/luser -type f -name '*.mpg' | tr "\n" "\000" | xargs -0 rm -f |
find the file "myfile.txt" in the folder /home/user/myusername/ | find /home/user/myusername/ -name myfile.txt -print |
Display who is logged on and what they are doing | w |
Remove empty directories from directory tree /srv/${x} | find /srv/${x} -type d -empty -exec rmdir {} \; |
Searches through the /usr/local directory for files that end with the extension .html. When these files are found, their permission is changed to mode 644 (rw-r--r--). | find /usr/local -name "*.html" -type f -exec chmod 644 {} \; |
Find all files/directories under /eserver6 directory and follow symlinks if needed | find /eserver6 -L |
Search the directory tree given as variable $dir for regular files | find $dir -type f |
Search the current directory recursively for files last modified within the past 24 hours ignoring .swp files and paths ./es* and ./en* | find -mtime 0 -not \( -name '*.swp' -o -path './es*' -o -path './en*' \) |
display all the files in the current folder which have the permissions 777 and which have been modified in the last 24 hours. | find . -perm 777 -a -mtime 0 -a -print |
force delete all the regular/normal files in the current folder | find . -type f -exec rm -fv {} \; |
Find symbolic links in directory /etc and below | find /etc -type l |
find all png images in the current folder and convert the to jpg images. print0 is used to handle the files which have new lines in their names | find . -name "*.png" -print0 | xargs -0 mogrify -format jpg -quality 50 |
Move all 10*jpg files under /path to 2010*jpg files under the same directory | find /path -type f -name "10*jpg" | sed 's/.*/mv &/' | sed 's/mv \\/& \120\2/' | sh |
set alias ".." for command "cd .." | alias ..='cd ..' |
Calculate the md5 sum of the sorted list of md5 sums of all ".py" files under "/path/to/dir/" | find /path/to/dir/ -type f -name *.py -exec md5sum {} + | awk '{print $1}' | sort | md5sum |
Find files that were modified more than 7 days ago but less than 14 days ago and archive them | find . -type f -mtime +7 -mtime -14 | xargs tar -cvf `date '+%d%m%Y'_archive.tar` |
Find all files/directoires that were modified more than 3 days ago under $dir directory tree | find $dir -mtime +3 |
Search for files only that end with .php and look for the string $test inside those files | find . -name \*.php -type f -exec grep -Hn '$test' {} \+ |
Count the number of directories under directory '/directory/' non-recursively | find /directory/ -maxdepth 1 -type d -print| wc -l |
Changes group ownership of 'myprog' to 'groupb'. | chgrp groupb myprog |
Prints reversed content of a file 'myfile.txt' with string numbers. | grep -n "" myfile.txt | sort -r -n | gawk -F : "{ print $2 }" |
Split "file.txt" excluding the first line into files of at most 4 lines each and with a prefix "split_" | tail -n +2 file.txt | split -l 4 - split_ |
SSH into "111.222.333.444" as user "tunneluser" without interpreting bash variables locally | ssh [email protected] <<\EOI |
Find all files/directories under current directory tree that have modified in the last 2 days and contain 'blah' (case insensitive) in their names | find . -iname '*blah*' \( -type d -o -type f \) -mtime -2 |
Find all empty files starting from the current directory and delete them | find . -type f -empty -print0 | xargs -0 /bin/rm |
Display a list of files with sizes in decreasing order of size of all the regular files under $dir directory tree that are bigger than $size in size | find $dir -type -f size +$size -print0 | xargs -0 ls -1hsS |
Find all symbolic links containing 'vim' in their names uder '/usr/bin' directory tree | find /usr/bin -name '*vim*' -type l |
Displays calendar of a previous, current and next month for December of 2120 year. | cal -3 12 2120 |
change the owner of all the files in folder /u/netinst to netinst | find /u/netinst -print | xargs chown netinst |
display all text files in the folder /home/you which have been modified in the last 60*24 hours | find /home/you -iname "*.txt" -mtime -60 -print |
search in the current folder for the file "myletter.doc" | find . -name myletter.doc -print |
Print the base name of the current working directory | basename "`pwd`" |
search for all the jpg files in the folder "/mnt/hda1/zdjecia/test1/" and copy these files to the folder /mnt/hda1/test/<same name as the found file> | find /mnt/hda1/zdjecia/test1/ -iname “*.jpg” -type f -exec cp {} -rv /mnt/hda1/test{} ‘;’ |
Search directory $dirname for regular files and save the result to $tempfile | find $dirname -type f > $tempfile |
Report available space on the file system containing /tmp in kilobytes. | df -k /tmp | tail -1 | tr -s ' ' | cut -d' ' -f4 |
copy all the files with the extension ".type" from one folder to a target directory | find "$sourcedir" -type f -name "*.type" | xargs cp -t targetdir |
Print the time to ping "8.8.8.8" followed by a time stamp if the ping is greater than 50 | ping 8.8.8.8 | awk -F"[= ]" '{if($10>50) {cmd="date"; cmd | getline dt; close(cmd) ; print $10, dt}}' |
Delete line 2 in numbered file "file" and renumber | grep -v '^2 ' file | cut -d' ' -f2- | nl -w1 -s' ' |
Save the list of files in the home directory tree whose names begin with "Foto" to `results.txt' | find ~ -name 'Foto*' > results.txt |
Search directory trees /usr/local/man and /opt/local/man for files whose names begin with 'my' | find /usr/local/man /opt/local/man -name 'my*' |
find all files that names are 'apt' and display detailed list | find / -name "apt" -ls |
List the unique parent directories of all .class files found in the entire filesystem | find / -name *.class -printf '%h\n' | sort --unique |
Find all files/directories under current directory tree whose paths match the regex 'filename-regex.\*\.html' | find . -regex filename-regex.\*\.html |
Print the absolute path of third-level files under the current directory tree and number the output | ls -d -1 $PWD/**/*/* | nl |
Find every JavaScript file in the wordpress directory | find wordpress -maxdepth 1 -name '*js' |
Find all sample*_1.txt files/directories under current directory and print 'program sample*-out sample*_1.txt sample*_2.txt' for each of them | find . -name "sample*_1.txt" | sed -n 's/_1\..*$//;h;s/$/_out/p;g;s/$/_1.txt/p;g;s/$/_2.txt/p' | xargs -L 3 echo program |
create a tar ball of current directory | tar cvf - `find . -print` > backup.tar |
Pushes directory path that saved in $line variable to the dirs stack, expanding symbol '~', if present, as home folder path. | pushd "${line/#\~/$HOME}"; |
Print the names of all files and directories in the current directory tree | find . |
Find all files with name ending with .txt and display only the filenames without full paths | find ./ -name "*.txt" | rev | cut -d '/' -f1 | rev |
Search all directory from /usr downwards for files whose inode number is 1234 and print them . | find /usr -inum 1234 -print |
Show manual for the find command | man find |
Force remove all files and folders in the physical current working directory | rm -rf "$(pwd -P)"/* |
Rename "file001abc.txt" to "abc1.txt" | mv file001abc.txt abc1.txt |
display a long listing of all the files in the /var folder which are bigger than 10MB. print0 is used to handle the files which have new lines in their names | find /var -size +10000k -print0 | xargs -0 ls -lSh |
Run the specified git command, paging through the output with raw characters written to the terminal, without initializing the terminal capabilities, and automatically exiting when the end of the output is reached. | git -c color.status=always status | less -REX |
Delete all files with 128128 inode number under current directory tree | find . -inum 128128 | xargs rm |
Recursively copies 'include/gtest' to '/usr/include', preserving all attributes, and copying symlinks as symlinks, without following in source files. | sudo cp -a include/gtest /usr/include |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.