nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Extract the contents of "Input.txt.gz", list the unique first comma separated field prefixed by the number of occurrences | zcat Input.txt.gz | cut -d , -f 1 | sort | uniq -c |
find all the regular/normal files in the current directory and print them skip searching all the directories in the current folders. | find * -type f -print -o -type d -prune |
Remove the "^M" characters from all *.ext files under /home directory and save the results to new files with _new appended in their names | find /home -type f -name "*.ext" -print0 | while read -r -d "$" -r path; do awk '{ sub; print }' $path > $path"_new"; done |
find all the regular files in a folder which do not start with the word find and assign the output to a variable | files = "`find "'"$dirs"'" -type f |& grep -v '^find: '`" |
remove all subdirectories named "CVS" under current dir | find . -type d -name CVS -exec rm -r {} \; |
Find all files under /mountpoint and below which have hard links | find /mountpoint -type f -links +1 |
Give all directories in the /path/to/base/dir tree read and execute privileges | find /path/to/base/dir -type d -exec chmod 755 {} + |
find all the regular/normal files in the current folder | find -type f |
Find all files/directories under /myfiles following symlinks if needed | find -L /myfiles |
Search the current directory recursively for regular files last changed 2 days ago | find . type -f -ctime 2 |
Find files that are writable by the user, the group, or both | find . -perm +220 -exec ls -l {} \; 2> /dev/null |
Find files readable only by the group | find . -perm g=r -type f -exec ls -l {} \; |
find all the regular/normal files in a folder and assign the output to a variable | files2 = "`find "'"$dirs"'" -type f`" |
find al the tmp directories in the current directory and create a dump of it | find . -type d -name tmp -prune -o -print | cpio -dump /backup |
find all files in current folder which are exactly 300MB | find . -size 300M |
Find all files in the current directory tree and replace string $1 with string $2 in them | find ./ -type f -exec sed -i "s/$1/$2/" {} \; |
search for a word in all the regular/normal files in the current folder and display the filename along with the matched text | find . -type f -exec grep -l linux {} \; |
set value of the variable "cmdstr" to the value of the alias "$aliascmd" | cmdstr=$ |
Copy all files ending in ".a" in directory trees matching "folder*" to "/path/to/dest" preserving directory hierarchy | find folder* -name '*.a' -print | cpio -pvd /path/to/dest |
Print how many files are inside each directory under the current one | find */ | cut -d/ -f1 | uniq -c |
Force the group stickiness for directories under /var/www | find /var/www -type d -print0 | xargs -0 chmod g+s |
Run 'chmod 0755' on all directories in the current directory tree | find . -type d -exec chmod 0755 {} \; |
Assign permissions 644 to files in the current directory tree | find . -type f -print0 | xargs -0 chmod 644 |
Save the short DNS lookup output of $WORKSTATION to 'WORKSTATION_IP' variable | WORKSTATION_IP=`dig +short $WORKSTATION` |
Find all files/directories with '.c' or '.h' extension under current directory tree and search for the regex provided by first positional argument and show the output by paging through one screenful at a time | find . -name '*.[ch]' | xargs grep $1 | less |
Print the file content of command "f" | cat `which f` |
Replace all occurrences of 'previousword' with 'newword' in all regular files with '.cpp' extension under '/myprojects' directory tree and modify them in-place | find /myprojects -type f -name *.cpp -print0 | xargs -0 sed -i 's/previousword/newword/g' |
List all *fink* files/directories under current directory | find . -name "*fink*" |xargs ls -l |
Print the sorted and unique parent directory paths appended with : of all the files that are executable by owner under ~/code directory without descending into hidden directories | find ~/code -name '.*' -prune -o -type f -a -perm /u+x -printf ':%h\n' | sort | uniq | tr -d '\n' |
display all the files in the usr folder which have been modified after Feburary 1st | find /usr -newermt "Feb 1" |
Write unbuffered output of "python -u client.py" to standard output and to "logfile" | python -u client.py | tee logfile |
Search for the regex ^catalina in the first line of each file under current directory | find -type f | xargs head -v -n 1 | grep -B 1 -A 1 -e '^catalina' |
Recursively change the owner and group of all files in the current directory to "andrewr" | chown -R andrewr:andrewr * |
Find all *1234.56789* files/directories under current directory | find . -name '*1234.56789*' |
Print space separated numbers from 1 to 5 | seq 5 | perl -ne 'chomp; print "$_ "; END{print "\n"}' |
Find all subdirectories of the current directory and run comand "cmd2" for each of them | find -maxdepth 1 -type d | while read dir; do echo $dir; echo cmd2; done |
Find all .java files under current directory | find . -print | grep '\.java' |
find all the files in the current directory ending with ".i" | find . -name ".*\.i" |
search all the files in the current folder using regex | find . -regex ".*/my.*p.$" |
display the change owner command for all the regular files in the current folder. | find . -type f -exec echo chown username {} \; |
Find all files/directories with permission $permissions under $directory directory tree | find "$directory" -perm "$permissions" |
Remove all regular files from the current directory tree except textfile.txt, backup.tar.gz, script.php, database.sql, info.txt | find . -type f ! -regex ".*/\" -delete |
Copy all directories recursively from "source/" to "destination/" excluding all files | rsync -a -f"+ */" -f"- *" source/ destination/ |
Find and uncompress all files in the current directory tree ending in ".csv.gz" | find . -name '*.csv.gz' -exec gzip -d {} \; |
Instantly kill all processes whose command is 'myprocess'. | kill -9 \`pgrep myprocess\` |
Rename "blah2" to "blah2-new" | mv blah2 blah2-new |
Find all .txt files in the user's home directory and below. | find ~/ -name '*.txt' |
Print a unique list of characters from standard input showing backslash escapes for non-displayables | od -cvAnone -w1 | sort -bu |
Find text in whole directory tree | find . -type f | xargs grep "text" |
Find files created in the last minute; works on Mac OS X | find / -newerct '1 minute ago' -print |
Exit the shell immediately if an error is encountered, treat references to unset variables as errors, disable overwriting existing files, and use the first non-zero exit code of a set of piped commands as the exit code of the full set of commands | set -o errexit -o nounset -o noclobber -o pipefail |
Display mime type of file specified by variable "file" | file -ib "$file" |
display all the files in the current folder along with the change time and display file names of the last 10 changed files | find . -type f -printf "%C@ %p\n" | sort -rn | head -n 10 |
kill a number of background jobs | jobs -p | tail -n [number of jobs] | xargs kill |
Search the "test1" directory recursively for regular files | find test1 -type f -print |
Convert "595a" into characters and then print the hexadecimal and printable characters of each byte | echo 595a | awk -niord '$0=chr' RS=.. ORS= | od -tx1c |
Revert $string value and print first 20 space-separated fields | echo $string | rev | cut -d ' ' -f -20 |
find all the files in the file system whcih have been modified in the last 1 day | find / -mtime -1 |
search for a word in all the shell scripts in the current folder and display the matched files. | find . -type f -name "*.sh" -exec grep -il landoflinux {} \; |
locate large files in /home/ for 'cleaning' | find /home -type f -size +100M -delete |
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` |
Remove files under /mnt/zip matching "*prets copy" with confirmation | find /mnt/zip -name "*prefs copy" -print0 | xargs -0 -p /bin/rm |
Find all files/directories in level 1 down the $queue directory with all positional parameters appended with the find command | echo "$queue" | xargs -I'{}' find {} -mindepth 1 -maxdepth 1 $* |
List detailed information about all Jar files in the current directory tree | find . -iname "*.jar" | xargs -n1 zipinfo |
Continuously print the seconds since Unix epoch and the ping time to "google.com" | ping google.com | awk -F'[ =]' 'NR>1{print system("echo -n $(date +%s)"), $11}' |
Search the current directory tree for files whose names contain "TextForRename" | find ./ -name "*TextForRename*" |
Search for files "file1" or "file9" | find . -name file1 -or -name file9 |
Recursively lists all files in a current folder in long format. | ls -ld $ |
search for files named "WSFY321.c" in a case-insensitive manner | find . -iname "WSFY321.c" |
Fetch a script from the web, and interpret it in the current shell. | source < |
For each line which has a common first field in file1.csv and file2.txt, output the first 4 fields of file1.csv | join -o 1.1,1.2,1.3,1.4 -t, < < |
Prints week day of a 31 day in a current month. | cal | awk -v date=31 -v FIELDWIDTHS="3 3 3 3 3 3 3 3" 'NR==2 {split} {for if print a[i]}' |
Find all files/directories named 'javac' under current directory | find . -name 'javac' |
Append the contents of "file.txt" to the current in-memory history list | history -r file.txt |
Hunting down files with at least one banana | find . -type f -print0| xargs -0 grep -c banana| grep -v ":0$" |
Display a named character dump of "test.sh" | od -a test.sh |
Archive showing progress "sourcefolder" to "/destinationfolder" excluding "thefoldertoexclude" | rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude |
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 print $1}' |
Print each character of "abcdefg" on a line | echo "abcdefg" | fold -w1 |
Rename file file.txt.123456 to file.txt | mv file.txt.123456 $ |
find all the files ending with jpg in current folder and display their count | find ./ -iname '*.jpg' -type f | wc -l |
List each directory in the current directory prefixed with its disk usage in human readable format and sorted from smallest to largest | du -sh */ | sort -n |
display all the files in current folder which have been changed in the last 2-6 days | find . -cmin +2 -cmin -6 |
Find all files/directories under /path/to/dir and set directory permission to 0755 and file permission to 0644 | find /path/to/dir -type d -exec chmod 0755 '{}' \; -o -type f -exec chmod 0644 '{}' \; |
Change the permission to 644 for all files under current directory | find . -type f | xargs chmod -v 644 |
Write "hey hey, we're the monkees" to standard output and as input to to "gzip --stdout" saved to "my_log.gz" without writing to disk | echo "hey hey, we're the monkees" | |
Delete the first line of "$FILE" using intermediate file "$FILE.tmp" | tail -n +2 "$FILE" > "$FILE.tmp" && mv "$FILE.tmp" "$FILE" |
Search the system for files and directories owned by user `admin' | find / -user admin -print |
search for the file "foo.txt" in the entire file system | find / -name foo.txt |
delete all the files in the current folder which do not belong to any user | find / -nouser -exec rm {}\; |
Find all directories that have been accessed $FTIME days ago under current directory tree | find . -type d -atime $FTIME |
Search regular files under ~/mail for string "Linux" | find ~/mail -type f | xargs grep "Linux" |
Find all files under directory tree /path/to/dir whose permissions are not 644 | find /path/to/dir ! -perm 644 |
Wrap each line in "longline" to a maximum of 30 characters | fold -w30 longline |
Find all PHP files under current directory that contain only one line | find . -type f -name '*.php' -exec wc -l {} \; | egrep "^\s*1\s" |
display the base name(name without extension) of all the ".NEF" files in the current folder | find . -name "*.NEF" -exec basename \{\} .NEF \; |
Calculates process depth of process with id $processid, and stores it in a 'depth' variable. | depth=$(pstree -sA $processid | head -n1 | sed -e 's#-+-.*#---foobar#' -e 's#---*#\n#g' -eq | wc -l) |
Counts lines in each *.php file, sorted by number of lines, descending. | find . -name '*.php' -type f | xargs wc -l | sort -nr |
Send TERM signal to process with id listed in '/var/run/DataBaseSynchronizerClient.pid' file | kill `cat /var/run/DataBaseSynchronizerClient.pid` |
Change permissions of all files ending ".php" under the current directory to 755 and print a count of modified files | find . -name "*.php" -exec chmod 755 {} + -printf '.' | wc -c |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.