nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
List current user's crontab. | crontab -l |
Set status code to a non-zero value if process with PID 4129 is running in a different namespace than init | bash -c "test -h /proc/4129/ns/pid && test '$' != '$'" |
Find all .txt files except README.txt | find . -type f -name "*.txt" ! -name README.txt -print |
Finds string beginning with 'IFS' in a 'set' output. | set | grep ^IFS= |
Find files/directories in entire file system that were accessed in less than a day ago | find / -atime -1 |
Installs git and bash-completion packages. | brew install git bash-completion |
find all the files that have been modified since the last time we checked | find /etc -newer /var/log/backup.timestamp -print |
Find all SGID files | find / -perm /g=s |
Remove all .mpg files in the /home/luser directory tree | find /home/luser -type f -name '*.mpg' | xargs rm -f |
display long list of all the files in the folder /home/peter which belong to no user and change the owner,group of all these files (after user confirmation) to "peter","peter" | find /home/peter -nouser -exec ls -l {} \; -ok chown peter.peter {} \; |
Enables shell option 'cdable_vars'. | shopt -s cdable_vars |
Recursively search through directory "test" in home directory, displaying names of all directories without full paths, ie. only the name part following the last slash of each directory. | find ~/test -type d -exec basename {} \; |
Remove trailing white spaces from all files under dir directory ensuring white space safety in the filename | find dir -type f -print0 | xargs -r0 sed -i 's/ *$//' |
Finds all strings with parent folder of path '$path' in 'file', and saves result in 'x' variable. | x=$(grep "$" file) |
create and list contents of the archive | tar cf - $PWD|tar tvf - |
Find all filenames ending with .c in the current directory tree | find -name "*.c" |
Find all the files which are changed in last 1 hour | find / -cmin -60 |
Find all *.txt files/directories under current directory | find . -name '*.txt' |
Find all regular files in the current directory tree last modified between 1 and 3 days ago and list them using format '%Tm %p\n' | find ./ -daystart -mtime -3 -type f ! -mtime -1 -printf '%Tm %p\n' |
Create a symbolic link named "wh" to "$wh" | ln -s "$wh" wh |
Search for all .mp3 files in the /mnt/usb directory tree | find /mnt/usb -name "*.mp3" -print |
Change owner to "bob" and group to "sftponly" of "/home/bob/writable" | sudo chown bob:sftponly /home/bob/writable |
Removes all empty folders within $DELETEDIR folder. | find "$DELETEDIR" -mindepth 1 -depth -type d -empty -exec rmdir "{}" \; |
Shows status of a shell option 'compat31'. | shopt compat31 |
Report file system containing path to the current working directory disk usage in kilobytes. | df -k . |
find all the files in the current folder and display those that are not present in the list "file.lst" | find . | grep -vf file.lst |
Counts all lines in $i file. | cat $i | wc -l |
Find all catalina* files/directories under /path/to/search/in | find /path/to/search/in -name 'catalina*' |
List all nfs mounts | mount -l -t nfs4 |
Find all files/directories under '/var/log' directory tree that bave been modified today | find /var/log -daystart -mtime 0 |
Save the day of the year from the time string "20131220" to variable 'DATECOMING' | DATECOMING=$(echo `date -d "20131220" +%j`) |
Archive "blanktest/" to "test/" deleting any files in the destination not found in the source | rsync -a --delete blanktest/ test/ |
Get the disk space used by all *.txt files/directories under folder 1 and folder2 | find folder1 folder2 -iname '*.txt' -print0 | du --files0-from - -c -s | tail -1 |
Rename "file.txt" in directories "v_1", "v_2", and "v_3" each to "v_1.txt", "v_2.txt", and "v_3.txt" respectively and print the conversion | rename -v 's#/file##' v_{1,2,3}/file.txt |
Search for the regex expanded by the variable $SEARCH in all regular files under $DIR directory tree | find "$DIR" -type f -exec grep -q "$SEARCH" {} + ; |
download contents from "https://raw.github.com/creationix/nvm/master/install.sh" and execute | curl https://raw.github.com/creationix/nvm/master/install.sh | sh |
Find all hidden files under current directory and remove them excluding the files specified in /tmp/list_files | find . -iname ".*" -exec bash -c "fgrep {} /tmp/list_files >/dev/null || rm -i {}" \; |
Removes resursively all files and folders named ".DS_Store". | find . -name ".DS_Store" -print0 | xargs -0 rm -rf |
Rename all *.jpg files to *.jpg$.jpg files under current directory | find . -name '*.jpg' -exec sh -c 'mv "$0" "${0%.JPG}$.jpg"' {} \; |
Execute `echo' for each file found | find . | xargs -n 1 echo |
display a long listing of all the directories in the current folder | find . -type d -exec ls -algd {} \; |
display list of all the files in the current folder which are empty. | find . -size 0 -ls |
Print an alert message containing the IP address and information of the user connecting via SSH | echo -e "ALERT - Shell Access on:' `date` `who` '\n\n' `whois $(who | cut -d'' -f1)`" |
search for files having python in filename | find / -name '*python*' |
Find any files in the current directory and its sub-directories that were last accessed more than 7 days or are larger than 20480 blocks in size. | find . -atime +7 -o -size +20480 -print |
Run command "program" as the current user | /usr/bin/sudo -u `whoami` `which program` |
Find all the files/directories under '/usr/local' directory tree which have been modified within the last day | find /usr/local -mtime -1 |
Rename all files in current directory to lowerase, overwriting any existing files. | rename -f 'y/A-Z/a-z/' * |
change the permission of all the files in the current directory to 664 and change the permission of all the directories in the current folder to 775. | find . \ , \ |
Find all directories recursively starting from / and skipping the contents of /proc/, and count them | find / -path /proc -prune -o -type d | wc -l |
Print what year it was 222 days ago | date '+%Y' --date='222 days ago' |
List all files in entire file system that are newer than the file $newerthan and older than the file $olderthan and sort them according to file modification time | find / -type f -name "*" -newermt "$newerthan" ! -newermt "$olderthan" -printf "%T+\t%p\n" | sort | awk '{print $2}' |
Show the internal memory size used by process whose PID is specified by variable PID. | top -l 1 -s 0 -stats mem -pid $PID |
find all the files in the current folder which are bigger than 1MB | find . — size +1000k -print |
Replace all instances of "STRING_TO_REPLACE" with "REPLACE_WITH" in file "index.html" and make a backup with suffix "bak" | sed -ibak -e s/STRING_TO_REPLACE/REPLACE_WITH/g index.html |
Connect as ssh user specified by variable USER to host whose IP address or host name is specified by HOST, and copy remote file specified by variable SRC to location on local host specified by variable DEST, disabling progress info but enabling debug info. | scp -qv $USER@$HOST:$SRC $DEST |
Find all files that are exactly 50 bytes | find / -size 50c |
Rename "fghfilea" to "jklfilea" | mv fghfilea jklfilea |
Delete all directories found in $LOGDIR that are more than a work-week old | find $LOGDIR -type d -mtime +5 -exec rm -rf {} \; |
find all jpg files in the current folder | find . -name "*.jpg" |
display all the C, CPP, Header files in the kat folder | find kat -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.h" \) |
display all the regular files in the current folder and do not search in sub folders | find "$dir" -maxdepth 1 -type f |
find the ten biggest files | find /home -type f -exec du -s {} \; | sort -r -k1,1n | head |
set alias "pwd" for command '/bin/pwd | pbcopy' | alias pwd='/bin/pwd | pbcopy' |
Execute "ls -l" on host "something" as user "root" | ssh root@something 'ls -l' |
Find all files in the /home/ directory tree that were last accessed more than 7 days ago | find /home -atime +7 |
Split "data.tsv" into files of at most 100 MiB preserving lines and use a prefix of "data.tsv." and numeric suffixes | split -C 100m -d data.tsv data.tsv. |
change owner of the file "file" to user user_name | chown user_name file |
display a long listing of all the files in the home folder which are bigger than 200MB | find /home -size +200M -exec ls -sh {} \; |
Find all files/directories with case insensitive name pattern $TARGET that are located in minimum 10 level down the current directory | find -mindepth 10 -iname $TARGET |
Show the subdirectories of the current directory | find . -maxdepth 1 -type d -print | parallel echo Directory: {} |
kills a running program 'python csp_build.py' | ps aux | grep 'python csp_build.py' | head -1 | cut -d " " -f 2 | xargs kill |
Delete all __temp__* files/directories under current directory tree | find . -name __temp__* -exec rm -rf '{}' \; |
Allow anyone to run command "Xvfb" as the owner of "Xvfb" | sudo chmod u+s `which Xvfb` |
Move all files from the `sourceDir' directory tree to the `destDir' directory | find sourceDir -mindepth 1 -print0 | xargs -0 mv --target-directory=destDir |
Locate all *.csv files under the current directory tree | find . -name "*.csv" -print |
display all the text and pdf files in the current folder | find . -regex ".*\$" |
Count the toal number of lines in all .py files in current directory tree | find . -name *.py -exec wc -l {} \; | awk '{ SUM += $0} END { print SUM }' |
Delete all files/directories named 'sample' under '/home/user/Series/' directory tree as super user | sudo find /home/user/Series/ -iname sample -print0 | sudo xargs -0 rm -r |
Replaces any occurences of '*favicon.ico*' in any subfolder with file '/root/favicon.ico'. | find . | grep favicon\.ico | xargs -n 1 cp -f /root/favicon.ico |
search for a word in all the shell scripts in the current folder and display the matched files.(case insensitive search in grep commad) | find . -type f -name "*.sh" -exec grep -il landoflinux {} \; |
find all the regular/normal files in the current direcoty which have not been accessed in the last 30 days. | find . -type f -atime +30 -print |
Search the current directory tree for directories | find "$PWD" -type d |
display all files in current folder excluding text files | find . ! -name "*.txt" |
Find all executable symlinks or upvoter-* files under maximum 1 level down the {} directory | find {} -name 'upvoter-*' -type f -or \( -type l \) -maxdepth 1 -perm +111 |
Print a listing of the `other' directory | $ find other -maxdepth 1 |
Find the files that have "644" permissions and modify them to have "664" permissions | find . -type f -perm 644 -exec chmod 664 {} \; |
display all the ".c" files in the current directory | find . -name \*.c -print |
Counts non-empty lines in file fileName. | cat fileName | grep -v ^$ | wc -l |
Recursively finds all files not like *.itp, *ane.gro, *.top in a current folder and removes them. | find . -depth -type f -not -name *.itp -and -not -name *ane.gro -and -not -name *.top -exec rm '{}' + |
Write the standard output and error of "ls" to the console and append it to "/tmp/ls.txt" | ls 2>&1 | tee --append /tmp/ls.txt |
Print the IP addresses for the current host name | hostname -I | cut -f1 -d' ' |
Find all regular files under and below /somepath that have extensions PDF, TIF, TIFF, PNG, JPG, JPEG, BMP, PCX, or DCX, ignoring the case and excluding "*_ocr.pdf" files | find /somepath -type f -iregex ".*\.(pdf\|tif\|tiff\|png\|jpg\|jpeg\|bmp\|pcx\|dcx)" ! -name "*_ocr.pdf" -print0 |
Shows strings that NOT match regex '^($|\s*#|\s*[[:alnum:]_]+=)' | echo "${line}" | egrep --invert-match '^($|\s*#|\s*[[:alnum:]_]+=)' |
Returns the single most recent file in a directory | ls -ltq <path> | head -n 1 |
Find all .sql files in the current directory recursively and print their path names separated by zeroes | find . -name '*.sql' -print0 |
Run an awk program on every TXT file found in the current directory tree | find . -name '*txt' -print -exec awk 'BEGIN {nl=1 ;print FILENAME} $9 !="" {if (nl<11) { print $0 ; nl = nl + 1 }}' {} \; |
Search for 'magic' in all regular files under current directory tree | find . -type f | xargs grep "magic" |
search for all the regular/normal mp3 files in the file system and move them to the folder /mnt/mp3 | find / -iname "*.mp3" -type f | xargs -I '{}' mv {} /mnt/mp3 |
display long listing of all the files in the folder "/myfiles" | find /myfiles -exec ls -l {} ; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.