nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Print lines 2960 to 2966 from the output of "history" | history | sed -n '2960,2966p' |
delete all the files in the current folder | find . -delete |
List all the emptry files in thecurrent directory only. | find . -maxdepth 1 -empty |
Prints processes with 'MDSImporte' in name, cutting off lines longer than screen width, exiting from less after end of output and saving printed lines on terminal after exit. | pstree | grep MDSImporte | less -SEX |
Print common characters in variable "$a" and "$b" | comm -12 <(echo $a|awk -F"\0" '{for print $i}') <(echo $b|awk -F"\0" '{for print $i}')|tr -d '\n' |
Search for "search term" in a sorted list of all files under current directory | find . | awk '{FS = "/" ; print "", NF, $F}' | sort -n | awk '{print $2}' | xargs grep -d skip "search term" |
Find all files/directories in entire file system that have "write" bit set for either the owner, the group, or others | find / -perm /222 |
search all undo files in the current folder and calculate the total size of them | find -name '*.undo' -exec wc -c {} + | tail -n 1 | cut -d' ' -f 1 |
Change directory to the directory containing the "oracle" executable | cd $(dirname $(which oracle)) |
search for all the regular/normal files in the current folder and display only video/image files | find folder -type f -print0 | xargs -0 file --media-type | egrep 'image|video' | cut -f1 -d : | tr '\n' '\0' |
print all PIDs of stopped processes | jobs -sl | awk '{print $2}' |
Print the terminal file of the users who are logged in with "admin" in their name | who |grep -i admin |cut -c10-20 |
List all files in a current folder, separating names with semicolon | ls -m | tr -d ' ' | tr ',' ';' |
Delete all regular files that reside in directory $OUTPUTDIR and below, and were last modified more than 7 days ago | find $OUTPUTDIR -type f -mtime +7 -delete |
List all *.txt files/directories under current directory | find . -name "*.txt" -exec $SHELL -c 'echo "$0"' {} \; |
Find all top level directories under /home that doesn't contain a file/directory named 'bin' | for d in /home/*/; do find "$d" -type d -name bin | grep -q . || echo "$d"; done |
Create a symbolic link named "/lib/libc.so.0" to "/lib/libc.so.6" | ln -s /lib/libc.so.6 /lib/libc.so.0 |
Print a list of case insensitive duplicate filenames in the current directory | ls | sort -f | uniq -i -d |
find all the files in the current folder which are bigger than 1MB | find . — size +1000k -print |
Merge already sorted files in the current directory ending in ".$suffix" | sort -m *.$suffix |
Calculate the SHA1 sum for the contents of the regular files in the path/to/folder directory tree | find path/to/folder -type f -print0 | sort -z | xargs -0 cat | sha1sum |
Search the given $directory for files with permissions stored in $permissions | find "$directory" -perm "$permissions" |
Finds file 'Subscription.java' and changes to containing folder. | cd `find . -name Subscription.java | xargs dirname` |
Find all *.cgi files/directories under current directory and change their permission to 775 | find . -name '*.cgi' -print0 | xargs -0 chmod 775 |
Find all files/directories named 'game' under current directory tree | find . -name game |
display all the files in the current folder excluding the directory aa | find . -type d ! -name aa |
move all files in the current folder another folder and do not move the files in the sub folder | find . -name "*" -maxdepth 1 -exec sh -c 'mv "$@" "$0"' /home/foo2/bulk2 {} + |
Read a line from standard input into variable "date" with prompt "BGC enter something", and storing typed backslash as backslash symbol | read -p 'BGG enter something:' -r data |
Find find symlinks pointing to /mnt/oldname* in the entire file system | find / -type l -lname '/mnt/oldname*' |
Set variable "extract_dir" to list of top-level directories and files contained in tar archive specified by variable FILE. | extract_dir=$ |
Find all files that belong to group root | find / -group root |
Search the /home/user1 directory tree for files whose names end in ".bin" | find /home/user1 -name "*.bin" |
Prints calendars of July, 2009 and July, 2010 side-by-side. | paste < < |
Search the .py files residing in the current directory tree for "something" | find . -name "*.py" -type f -exec grep "something" {} \; |
find all hidden files in the current folder which have been modified after profile file | find . -type f -name ".*" -newer .cshrc -print |
Sort standard input in alphabetical order | sort |
Print differences between files in directories folder1 and folder2 recursively, with unified context, ignoring changes in the amount of white space | diff -bur folder1/ folder2/ |
Go to last directory with name starting with a number, useful for timestamped directory names. | cd "$" |
Find files on the system modified more than 90 minutes ago | find / -mmin +90 |
Traverse the filesystem just once, listing setuid files and directories into /root/suid.txt and large files into /root/big.txt. | find / \ , \ |
Prints days since epoch | echo $(($ / 60 / 60 / 24)) |
Find files under current directory that are not newer than $date_time in regards of modification time | find . -type f -not -newermt "$date_time" |
Save the list of all .py files under and below the current directory that contain "something" in their pathnames to output.txt | find . -name '*.py' | tee output.txt | xargs grep 'something' |
Find all regular files under /home/www and replace every occurrences of 'subdomainA.example.com' with 'subdomainB.example.com' in those files | cd /home/www && find . -type f -print0 | xargs -0 perl -i.bak -pe 's/subdomainA\.example\.com/subdomainB.example.com/g' |
Find all files/directories with '.in' extension in the directory $directory and its subdirectories | du -a $directory | awk '{print $2}' | grep '\.in$' |
find files in current folder ending with ".c" or ".h" or ".ch" and search for a word in these files and enable color highlighting of the matched text | find . -name "*.[ch]" -exec grep --color -aHn "e" {} \; |
Print the output of history without line numbers | history | cut -d' ' -f4- | sed 's/^ \(.*$\)/\1/g' |
Find files owned by the "shadow" group | find / -group shadow |
Recursively removes all files and folders named '.svn' in a current folder. | find . -name .svn |xargs rm -rf |
Search directory tree /srv/${x} for regular files accessed at least 10080 minutes ago, and remove those files | find /srv/${x} -mindepth 1 -type f -not -amin -10080 -exec rm {} \; |
Print the most recently modified file | ls -1tr * | tail -1 |
Find all files starting from the current directory which are larger than 100MB | find . -size +100M |
Print file type of command "gcc" | file -L `which gcc` |
Check the environment variables generated by switching to the root account. | sudo env |
Find all the files which are accessed in last 1 hour | find / -amin -60 |
Serach for all the files starting with grep in man pages | find /usr/share/man/ -regex grep.* |
Find all files in maximum 1 level down the current directory that were modified less than 1 day ago | find -maxdepth 1 -type f -mtime -1 |
find all the files in the current directory and display them | find . -exec echo {} ; |
Split the contents of "file1 file2 ... file40000" into 1445 files in a round robin fashion with prefix "outputprefix" and numeric suffixes | cat file1 file2 ... file40000 | split -n r/1445 -d - outputprefix |
Save the list of directories modified a fortnight ago to `deploy.txt' removing the leading ./ from the file names | find . -type d -mtime 14 -printf "%P\n" > deploy.txt |
use regex with find command | find . -regextype sed -regex ".*/[a-f0-9\-]\{36\}\.jpg" |
Remove all directories called "test" from the current directory tree | find -name "test" -type d -delete |
find all the word press configuration php files in the folder /var/www | find /var/www/ -name wp-config.php |
Find all files in and below the home directory that have been modified in the last 90 minutes | find ~ -mmin -90 |
Find all files under $x directory and set read-write permission for owner and group and no permission for other for those files | find ${x} -type f -exec chmod ug=rw,o= '{}' \; |
Delete all .svn files/directories under current directory | find . -name .svn -delete |
Print list of all user names who are logged in | who | sed -e 's/[ \t].*//g' |
Calculate the md5 sum of the md5 sum of all the files sorted under "$path" | find "$path" -type f -print0 | sort -z | xargs -r0 md5sum | md5sum |
search for all the text files in the folder /foo and delete them | find /foo/ -name "*.txt" -exec rm -v {} \; |
display the sum of disk used by all the access.log files in /var/www folder | find /var/www/ -type f -name «access.log*» -exec du -k {} \;|awk '{s+=$1}END{print s}' |
Find all regular files in the current director and set their permissions to '644'. | find ./ -type f -exec chmod 644 {} \; |
Execute "awk -F, '$1 ~ /F$/'" on contents of "file.gz" | zcat file.gz | awk -F, '$1 ~ /F$/' |
Check which package the "sort" command belongs to in rpm | rpm -qf `which sort` |
find all the perl files in the current folder | find . -type f -name "*.pl" |
Delete all directories under <directory_name> that contain directories named 'test' and 'live' | find <directory_name> -type d -exec sh -c "cd {} && [ -d live ] && [ -d test ] && cd ../ && echo \"Deleting {}\" && rm -rvi {} " {} \; |
sort all the regular files in the "$DiskName" directory which have been modified in the last 3*24 hours and which are bigger than 5Kb based on their size and save the output to the "$TMPFILE" | find $DiskName -type f -mtime -3 -size +5000 -exec ls -ld {} \; 2>/dev/null | sort -n -k 5.1,5 >> $TMPFILE |
Check if 'nullglob' shell option is enabled, and if so, saves its status in 'is_nullglob' variable. | is_nullglob=$ |
Display file.txt with lines numbered, and page interactively through the result. | cat -n file.txt | less |
Show ls's detailed output for all files named "something" | find . -name something -exec ls -l {} \; |
List all regular files in the current directory tree | find . -type f -exec ls -l '{}' \; |
Search files "file-containing-can't" in the current directory tree for the string "can't" | find . -name "file-containing-can't" -exec grep "can't" '{}' \; -print |
display the contents of all the text files in the current directory | find . -name '*.txt' -exec cat {} \; |
Recursively changes group ownership of everything in '/home/secondacc/public_html/community/' to 'fancyhomepage'. | chgrp -R fancyhomepage /home/secondacc/public_html/community/ |
Search the current directory tree for regular files owned by user "www" | find -type f -user www |
Extract any line in "fileA" which does not appear as the first word of any line in "fileB" | comm -23 <(sort fileA) <(cut -d' ' -f1 fileB | sort -u) |
count lines of C or C++ or Obj-C code under the current directory | find . \( -name "*.c" -or -name "*.cpp" -or -name "*.h" -or -name "*.m" \) -print0 | xargs -0 wc |
find all the symbolic links in the current folder | find /etc -type l -print |
display all the directories in the current folder excluding those that are present in the .svn directory tree | find -type d -path '.svn' -prune -o -print |
display all symbolic links in current folder | find . -lname "*" |
create directory ".hiddendir" | mkdir .hiddendir |
Find all directories under /home/username/public_html/sites/all/themes and set their permission to 750 | find /home/username/public_html/sites/all/themes -type d -exec chmod 750 {} + |
Remove junk files modified more than 31 days ago recursively | find /path/to/junk/files -type f -mtime +31 -print0 | xargs -0 -r rm -f |
display all directories which have not been accessed in the last 24*3 hours | find -type d -and -atime +3 |
Find and copy all log files in the current directory tree to /tmp/log-files | find . -name \*.log -print0 | xargs -I{} -0 cp -v {} /tmp/log-files |
Print only unique lines of 'file_name' file | cat -n file_name | sort -uk2 | sort -nk1 | cut -f2- |
Search for the regex "+\S\+" in file 'in.txt' and print the matches by replacing newlines with comma | grep -o "+\S\+" in.txt | tr '\n' ',' |
display all the files having spaces in the current folder | find . -name "filename including space" |
Copy all regular files from the current directory tree to /tmp | find . -type f -exec sh -c 'cp "$@" /tmp' {} + |
Print a colon-separated list of all directories from the $root directory tree | find $root -type d -printf '%p:' |
find all the directories in the current folder that are empty(size 0 bytes) | find -type d -empty |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.