nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Copy local file "$1" to host "$2" into host directory "$3" | cat $1 | ssh $2 "mkdir $3;cat >> $3/$1" |
set alias "lvim" for command "vim -c \"normal '0\"" | alias lvim="vim -c \"normal '0\"" |
Find all the files which are greater than 50MB but less than 100MB in size | find / -size +50M -size -100M |
change the permissions of all regular/normal files in the current directory | find . -type f | xargs chmod 664 |
find all the png files in the current folder which begin with the word image | find . -name "image*.png" |
find all files in the current folder which are bigger than 10MB and less than 50 MB | find . -size +10M -size -50M -print |
delete all the regular files in the temp folder which have not been modified in the last 24 hours | find /tmp/ -type f -mtime +1 -print0 | xargs -0 -n1 rm |
Display all lines contained in 'dax-weekly.csv' in reverse order. | cat dax-weekly.csv | awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }' |
Print variable "$OPTARG" "$opt" times | yes "$OPTARG" | head -$opt |
Search for files/directories named 'fileName.txt' under current directory tree without traversing into './ignored_directory' | find . -path ./ignored_directory -prune -o -name fileName.txt -print |
Print the byte count of all regular files found in the current directory tree | find . -type f | xargs | wc -c |
find all the files that have been modified exactly 2 days ago | find -mtime 2 |
display all the trace files from the folder $DBA/$ORACLE_SID/bdump/ which have not been accessed in the last 7*24 hours | find $DBA/$ORACLE_SID/bdump/*.trc -mtime +7 |
Find all files/directories under /home/feeds/data directory | find /home/feeds/data |
Make directory "dir1" | mkdir dir1 |
List the files from the current directory tree that contain lines matching regular expression '^Subject:.*unique subject' | find . -type f -print | xargs grep -il '^Subject:.*unique subject' |
find all the files in the folder "/mp3-collection" which are bigger than 10MB excluding those that start with the word Metallica | find /mp3-collection -size +10000k ! -name "Metallica*" |
Print content of 'filename' file, showing all non-printing characters and displaying $ at the end of each line. | cat -v -e filename |
Finds recursively all files not having extension .o in '/path/' that contain 'pattern', and prints matched strings with string number and file name. | grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern" |
Find all directories under /fss/fin | find /fss/fin -type d |
Search for 'some string' in all *js files under current directory and show the matched lines with line numbers | find . -name '*js' -exec grep -n 'some string' {} \; |
Takes folder name of file $0, changes backslashes to forward ones and saves result in $basedir variable. | basedir=$(cygpath -am "$") |
Find all .php files starting from the root directory / | find / -name "*.php" |
Echo each command before running | set -x |
Print all the banned IPs from your server along with their origin using the geoip-bin package | zcat /var/log/fail2ban.log* | gawk '/.*Ban.*/ {print $7};' | sort | uniq -c | sort | gawk '{ "geoiplookup " $2 "| cut -f2 -d: " | getline geoip; print $2 "\t\t" $1 " " geoip}' |
Read a line of standard input with prompt "Enter the path to the file: " and suggestion "/usr/local/etc/" and save the response to variable "FILEPATH" | read -e -p "Enter the path to the file: " -i "/usr/local/etc/" FILEPATH |
Search the current directory tree for files containing "bash" in their names | find . -name "*bash*" | xargs |
find all the text files in the current folder starting with "somefiles-" and prepend the first line | find . -name "somefiles-*-.txt" -type f -exec sed -i 'iText that gets prepended ' -- '{}' \; |
Show mv commands to move all *.pdf.marker files and their corresponding *.pdf files under ${INPUT_LOCATION} to ${OUTPUT_LOCATION} | find ${INPUT_LOCATION} -name '*.pdf.marker' -exec sh -c 'echo mv $0 `dirname $0`/`basename $0 .marker` $1' {} ${OUTPUT_LOCATION} \; |
List files ending in .html and residing in the current directory tree | find . -name "*.html" |
Set permission of "file" to read only for the owner | chmod 600 file |
display all the files in the home folder | find $HOME -print |
find all the regular files in the current directory which do not have a read permission | find -type f ! -perm -444 |
Find all directories under current directory and set their permission to 755 | find -type d exec chmod 755 {} + |
Find all 100MB files in file system and delete them using rm command | find / -size +100M -exec rm -rf {} \; |
Find all *.txt files/directories under current directory discarding 'Permission denied' errors | find . -name "*.txt" -print | grep -v 'Permission denied' |
Set permissions of all directories under "/path/to/base/dir" to 755 | chmod 755 $(find /path/to/base/dir -type d) |
Delete all files under /path/to/files that are not newer than dummyfile | find /path/to/files -type f ! -newer dummyfile -delete |
Delete files containing whitespaces without recursion | find . -name '*[+{;"\\=?~()<>&*|$ ]*' -maxdepth 0 -exec rm -f '{}' \; |
find all regular/normal files in current folder which have been modified in the last 60 minutes | find -type f -mtime -60 |
Print source directory of bash script | dirname "$" |
Find all files/directories with '.txt' extension under '/home' directory tree that are exactly 100KB in size | find /home -name "*.txt" -size 100k |
Execute awk script "script.awk" on "File2" and "File1" and format output as a table | awk -f script.awk File2 File1 | rev | column -t | rev |
Delete all files under $INTRANETDESTINATION/monthly directory tree that were modified more than 366 days ago | find $INTRANETDESTINATION/monthly -mtime +366 -exec rm {} \; |
Find all files, folders, symlinks, etc matching pattern "*.php" in the current directory recursively | find . -name \*.php |
Find all files/directories named orm.properties under /eserver6/share/system/config/cluster directory | find /eserver6/share/system/config/cluster -name "orm.properties" |
Display list of files ending with '.txt' in the current folder to the terminal twice and output it to the text file "txtlist.txt" | ls *.txt | tee /dev/tty txtlist.txt |
Renames all *.html files in a current directory to *.txt files. | ls *.html | xargs -I {} sh -c 'mv $1 `basename $1 .html`.txt' - {} |
Find all files accessed on the 29th of September, 2008, starting from the current directory | find . -type f -newerat 2008-09-29 ! -newerat 2008-09-30 |
Remove all white space from "infile.txt" and wrap each line to 80 characters | cat infile.txt | tr -d "[:space:]" | fold -80 |
sort based on size and display top ten small normal/regular files in the current folder | find . -type f -exec ls -s {} \; | sort -n | head -10 |
display all regular/normal files in current folder | find . -type f |
Write "Some console and log file message" to standard output and "/dev/fd/3" | echo "Some console and log file message" | tee /dev/fd/3 |
Find all files named "test2" in the current directory | find -name test2 -prune |
locate large files in /home/ for 'cleaning' | find /home -type f -size +100M -print0 |xargs -0 rm |
Gets MAC addresses of all IP4 network interfaces. | ifconfig -a | awk '/^[a-z]/ { iface=$1; mac=$NF; next } /inet addr:/ { print mac }' | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' |
search in the current folder for all the directories with the name "test" | find . -type d -name test |
Finds file 'Subscription.java' and changes to containing folder. | cd $ |
Finds shell options like 'checkjobs' with their state. | shopt -p | grep checkjobs |
Prints the file path composed from the path where symlink target file is located, and name of the symbolic link itself. | echo "$(dirname $(readlink -e $F))/$(basename $F)" |
Remove all *.swp files/directories under current directory | find . -name "*.swp"-exec rm -rf {} \; |
Search the /var/www/ tree for files not owned by user `apache' | find /var/www ! -user apache -print0 | xargs -0 |
Prints total count of lines of all *.py files in a current folder and subfolders. | find . -name "*.py" -exec wc -l {} \; | awk '{ SUM += $0} END { print SUM }' |
find the file arrow.jpg in the entire file system | find / -name arrow.jpg |
Delete all .svn directories under current directory | find . -type d -name .svn -print0|xargs -0 rm -rf |
Find all .php files in all directory trees matching pattern `/srv/www/*/htdocs/system/application/' and search those files for string "debug (" | find /srv/www/*/htdocs/system/application/ -name "*.php" -exec grep -H "debug (" {} + |
display all the regular/normal files in the entire file system | find / -type f -exec echo {} \; |
Opens gcc info manual and selects "option index" menu entry. | info gcc "option index" |
Print the entire saved command history | history |
Rename "new" to "old" and make a backup if "old" exists | mv new old -b |
Search the current directory recursively for regular files, skipping hidden files in the current directory | find * -type f -print |
Find all directories under /var/www/some/subset and set their SGID bit | sudo find /var/www/some/subset -type d -print0 | xargs -0 chmod g+s |
Find all 15MB files in entire file system | find / -size 15M |
change the permissions of all the files ending with "fits" in the folder "/store/01" and save the output file names to a log file | find /store/01 -name "*.fits" -exec chmod -x+r {} \; -exec ls -l {} \; | tee ALL_FILES.LOG |
Search the /Path directory tree for files whose pathnames match pattern "/Path/bar*" and whose names match pattern "file_name*" | find /Path -path "/Path/bar*" -name "file_name*" |
Print the list of .txt files under and below the current directory | find . -name '*.txt' -print0|xargs -0 -n 1 echo |
Decompress "file2.txt" and "file1.txt" and print lines in "file1.txt" that match the 5th tab separated field in "file2.txt" | awk -F'\t' 'NR==FNR{a[$5];next} $5 in a' <(zcat file2.txt) <(zcat file1.txt) |
Make directory "/tmp/googleTestMock" | mkdir /tmp/googleTestMock |
Count the number of lines in every regular .rb file in the current directory tree | find . -name "*.rb" -type f -print0 | xargs -0 wc -l |
delete all the empty directories in the current folder | find . -type d -empty -exec rmdir {} \; |
Find empty files in the test directory | find test -empty |
Search the current directory tree for regular files whose names end in "log" | find `pwd` -name "*log" -type f |
Find all files and directories last modified less than a day ago and copy to "../changeset" creating directories as needed | find * -mtime -1 -daystart -print0 | cpio -pd0 ../changeset |
Print which files differ in "dir1" and "dir2" recursively | diff -qr dir1/ dir2/ |
Print each logged in user's username and full name | finger -l | grep "Name:" | tr -s ' ' | cut -d " " -f 2,4- | sort | uniq |
Display a count of regular files in each directory at the current level. | find -P . -type f | rev | cut -d/ -f2- | rev | cut -d/ -f1-2 | cut -d/ -f2- | sort | uniq -c |
find all the files in the folder "myfiles" which have not been accessed in the last 30 days | find /myfiles -atime +30 |
Find all files under /mnt/naspath directory without descending into .snapshot directory that were modified in last 24 hours with null character as the delimiter | find /mnt/naspath \! \ -type f -mtime 0 -print0 |
display long listing of all the text files in the current folder (plus at the end executes quickly by sending bulk data as input to the command in exec) | find . -name "*.txt" -exec ls -la {} + |
Displays a tree of all process alongside their command line arguments. | pstree -a |
display all regular files in the folder image-folder | find image-folder/ -type f |
change the permissions of all regular/normal files in the current directory, print0 is used for handling files with newlines in their file name | find . -type f -print0 | xargs -0 chmod 664 |
delete all the text files starting with the name "oldStuff" in the file system | find / -name "oldStuff*.txt" -delete |
Make directories "Labs/lab4a/folder1", "Labs/lab4a/myfolder", and "Labs/lab4a/foofolder" | mkdir Labs/lab4a/{folder1,myfolder,foofolder} |
Change permissions of ".git/hooks/pre-commit" to 777 | sudo chmod 755 .git/hooks/pre-commit |
find all the files in the current directory and search for the word "pw0" in them. | find . -exec grep -i "pw0" {} \; |
Find all files/directories under directory '.cache/chromium/Default/Cache/' which are bigger than 100MB and which are atleast 1 level deep and delete them | find .cache/chromium/Default/Cache/ -mindepth 1 -size +100M -delete |
Delete all regular files under current directory | find . -type f -print0 | xargs -0 /bin/rm |
Search the current directory tree for files matching regular expression '^myfile[0-9][0-9]?$' | find . -\ |
Recursively lists all files in a current folder and prints full path along with modification time. | stat --printf="%y %n\n" $(ls -tr $) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.