nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Enables shell option 'autocd'. | shopt -s autocd |
find all files in the current folder which end with macs | find -name '*macs' |
Grab "variable = value" pairs from a windows style .ini file into the current shell. | source < |
Finds the folder where temporary files would be written to, and save path to it in a 'TMPDIR' variable. | TMPDIR=`dirname $` |
Search for '“foobar”' in all files starting with '‘' and ending with '’' and contain '.' in their names in the entire filesystem and display only the matched files | find / -name ‘*.*’ -exec grep -il “foobar” {} \; |
search for the word "slrn" in all the files in the current folder | find ./ -exec grep -q 'slrn' '{}' \; -print |
Remove all 'a.out', '*.o', and 'core' files in the current directory tree | find . \( -name a.out -o -name '*.o' -o -name 'core' \) -exec rm {} \; |
Find all files/directories ignoring *~ files/directories without descending into .snapshot directory with null character as the delimiter | find . -name .snapshot -prune -o \( \! -name *~ -print0 \) |
Set permissions of command "node" to 755 | sudo chmod 755 $ |
Print fourth column of space-separated data from text file text.txt. | cat text.txt | cut -d " " -f 4 |
find files which full path name is /tmpfoo/bar under foo directory and print | find foo -path /tmp/foo/bar -print |
change the permission of all directories in current folder to 755. | find . -type d -exec chmod 755 {} \; |
find a.out, *.o and core files under the current directory and sub-directories and delete them. | find . \( -name a.out -o -name '*.o' -o -name 'core' \) -exec rm {} \; |
Find all files in the current directory tree whose size is greater than 1MB, and move them to the "files" folder with confirmation | find . -size +1M -ok mv {} files \+ |
Find all files/directores under /etc filter them by searching for 'test' in their name and run the file command on each of them | find /etc -print0 | grep -azZ test | xargs -0 file |
create an archive using 'pigz' as a compress program | tar -c --use-compress-program=pigz -f tar.file dir_to_zip |
list all files under the current directory, redirecting error messages to the output, filtering out lines containing the text "permission denied" and writing the output to a file called files_and_folders | find . 2>&1 | grep -v 'permission denied' > files_and_folders |
Show files in maximum 1 level down the current directory that were modified less than 1 day ago from today | less `find -maxdepth 1 -type f -daystart -mtime -1` |
Attempt to connect as root via ssh to host whose IP address or hostname is specified by environment variable IPADDRESS - this will normally fail because ssh servers normally don't accept root logins. | scp -rp "DAILY_TEST_FOLDER" "root@${IPADDRESS}:/home/root/" |
Find all *.md files in entire file system and convert them to HTML files | find / -name "*.md" -type f -exec sh -c 'markdown "$0" > "$0.html"' {} \; |
Find all .txt files in the current directory tree and edit them with `vim' | find . -name "*.txt" | parallel -Xj1 --tty vim |
Replace spaces with underscores in the names of all files and directories in the "/tmp" directory tree | find /tmp/ -depth -name "* *" -execdir rename 's/ /_/g' "{}" \; |
List directories under current directory | find . -type d |
Save the system host name to variable "myHostName" | myHostName=`hostname` |
List the names of the directories in current directory without going into sub-directories | find . -mindepth 1 -maxdepth 1 -type d -printf "%P\n" |
Print all lines of "seq 1 10" except the last 3 | seq 1 10 | perl -e '@x=x3;while{print shift @x;push @x,$_}' |
Search the current directory tree for regular files omitting directory `omit-directory' | find . \( -name omit-directory -prune -o -type f \) -print |
Print the base name of the current working directory | basename `pwd` |
Find all files/directories that are newer than 'ttt' by modification time or owned by the user 'wnj' in the entire filesystem | find / \ -print |
Search for 'string-to-find' in all files under current directory tree matching the regex 'filename-regex.\*\.html' in their paths and show the matched lines along with the filenames | find . -regex filename-regex.\*\.html -exec grep -H string-to-find {} \; |
Remove all regular files found in and below /path | find /path -type f -print | xargs rm |
Removes all files from current folder but 5 newest ones, ignoring folders in a files list. | find . -maxdepth 1 -type f | xargs -x ls -t | awk 'NR>5' | xargs -L1 rm |
Change owner of "my_test_expect.exp" to "el" | sudo chown el my_test_expect.exp |
List all existing environment variables in the current shell. | env | awk -F= '/[a-zA-Z_][a-zA-Z_0-9]*=/ { if (!system) print $1 }' | sort | uniq |
Find recursively the latest modified file in the current directory | find . -type f -print0 | xargs -0 ls -ltr | tail -n 1 |
Find all *.txt files on the vfat file system | find / -name "*.txt" -fstype vfat 2> /dev/null |
display a long listing of all the files that begin with the name "Metallica" in the entire file system | find / -name 'Metallica*' -exec ls -l {} \; |
Find all *.php files under current directory and change their permission to 644 | find . -type f -name '*.php' -exec chmod 644 {} \; |
Find all directories named $1 under $HOME directory tree and remove them | find $HOME -type d -name $1 -exec echo {} ';' -exec rm -rf {} ';' |
Prefix all files and folders in the current directory with "PRE_" | find * -maxdepth 0 ! -path . -exec mv {} PRE_{} \; |
display all the directories in the current folder excluding those that are present in the aa directory tree | find . -type d -name aa -prune -o -print |
Print lines in "file1" that exist in "file2" | join -t " " -j 1 < < |
Display only mimetype of myfile.txt, without the filename. | file -bi myfile.txt |
Find all *.jpg files under current directory and print only duplicate names | find . -name \*.jpg -exec basename {} \; | uniq -d |
Find broken symlinks in current directory | find -L -type l |
Print the list of files in the current directory tree skipping Git files | find . -path './.git' -prune -o -type f |
Find all *.txt files under /foo and print their total size | find /foo -name "*.txt" -exec du -hc {} + | tail -n1 |
Adjust the timestamp of 'filename' by subtracting 2 hours from it. | touch -d "$ - 2 hours" filename |
Delete all contents form the files that contain the case insensitive regex 'stringtofind' in maximum 1 level down the / directory excluding other partitions | find / -maxdepth 1 -xdev -type f -exec grep -i "stringtofind" -q "{}" \; -print0 | xargs -0 sed '/./d' |
Counts the number of lines in *.php and *.inc files in a current folder and subfolders. | find . -name '*.php' -o -name '*.inc' | xargs wc -l |
Print a line of 99 '=' characters | seq -s= 100|tr -d '[:digit:]' |
Find all .zip files starting from the current directory which are owned by user tommye | find . -type f -user tommye -iname "*.zip" |
Search the current directory recursively for .m4a files | find . -type f -iname *.m4a -print |
Search the ./bin directory recursively for files called "cp" | find ./bin -name “cp” |
Find x* files/directories under /tmp directory whose status was changed less than 1 day ago and move them to ~/play | find /tmp/ -ctime -1 -name 'x*' -exec sh -c ' exec mv "$@" ~/play/' sh {} + |
Calculate the crc32 of "testring" | echo -n teststring | gzip -1 | pigz -lv |
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 |
Numerically sort file "temp.txt" by the second "-" separated value of each line ordered from highest value to least value | tac temp.txt | sort -k2,2 -r -u |
Read a line of standard input into variable "input_cmd" with prompt "command : " | read -p "command : " input_cmd |
Search the files from directory tree "dirname" for string "foo" | find dirname -print0 | xargs -0 grep foo |
find all files in the folder /etc which have been modified after /tmp/foo | find /etc -newer /tmp/foo |
Find all files/directories named '.todo' under $STORAGEFOLDER directory tree and print their parent paths | find "$STORAGEFOLDER" -name .todo -printf '%h\n' |
display all the files in current folder which have been changed in the last 24 hours | find . -ctime -1 -print |
Overwrite a file 'my-existing-file' with random data to hide its content | shred my-existing-file |
display all php,xml and phtml files in current folder | find . -name '*.php' -o -name '*.xml' -o -name '*.phtml' |
Automatically spell check file "text.txt" using "ispell" command | yes 0 | script -c 'ispell text.txt' /dev/null |
Search the .cs files of the current directory tree for string "content pattern" | find ./ -type f -iname "*.cs" -print0 | xargs -0 grep "content pattern" |
list all js files under currect directory exculde the directory which path contain "/path/to/search/exclude_me" or name isexclude_me_too_anywhere | find /path/to/search -type d -prune -o -type f -name '*\.js' -print |
Print the day at 1 day ago in 2 months from now | date -d "$(date -d "2 months" +%Y-%m-1) -1 day" +%a |
Find all files & directory which have write permission for group , remove the permission from group | find . -perm -20 -exec chmod g-w {} ; or find . -perm -20 -print | xargs chmod g-w |
View history using "vim" | vim < |
Change the owner of all files in "/empty_dir/" to "root" using at most 10 files at a time | ls /empty_dir/ | xargs -n10 chown root |
search for all the files in the current folder which start with "my" | find . -name 'my*' |
Write differences between files "a.txt" and "b.txt" side-by-side and not outputting common lines to file "c.txt". | diff -a --suppress-common-lines -y a.txt b.txt > c.txt |
Sends current job to the background. | bg |
Find all files on the system that are world writable | find / -wholename '/proc' -prune -o -type f -perm -0002 -exec ls -l {} \; |
archive all the normal/regular files in the current directory which have been modified in the last 24 hours. | find . -mtime -1 -type f -exec tar rvf "$archive.tar" '{}' \; |
Read a single sample of raw audio in the form of a number between -32768 and 32767 | parec --raw --channels=1 --latency=2 | od -N2 -td2 | head -n1 | cut -d' ' -f2- | tr -d ' ' |
Recursively finds file some_file_name.xml file and prints strings with "PUT_YOUR_STRING_HERE" preceding each found string with file name. | find . -type f -name some_file_name.xml -exec grep -H PUT_YOUR_STRING_HERE {} \; |
Search the current directory tree for files without "test" in their path names | find . -not -regex ".*test.*" |
Make directories to "/my/other/path/here/" as needed | mkdir -p /my/other/path/here/ |
display all the regular files in the current folder excluding those that are present in the path "git" | find . -path "*.git" -prune -o -type f -print |
Get domain name with 'google' from address $IP | dig -x $IP | grep PTR | cut -d ' ' -f 2 | grep google | cut -f 5 |
Counts number of *.php files in a current folder and subfolders. | find . -name '*.php' | wc -l |
Move all directories from the `sourceDir' directory tree to the `destDir' directory | find sourceDir -mindepth 1 -type d -print0 | xargs -0 mv --target-directory=destDir |
create directory ".hiddendir" | mkdir .hiddendir |
Remove all files under $DIR that were accessed more than 5 days ago | find "$DIR" -type f -atime +5 -exec rm {} \; |
Print a list of JPG files residing in the current directory tree | find . -name “*.jpg” |
Display differences between file1 and file2 side-by-side. | diff -y file1 file2 |
Find all *.ini files | find . -name *.ini |
Compress from standard input with gzip | gzip |
Return the files that are newer than file `myfile' | find / -newer myfile |
Print the path names of all regular .rb files prefixing them with string "Hello, " | find . -name "*.rb" -type f | xargs -I {} echo Hello, {} ! |
Find all files in the current directory tree that are not newer than some_file | find . ! -newer some_file |
Find List empty directories | find -maxdepth 1 -type d | sort | while read -r dir; do n=$; let n--; if [ $n -eq 0 ]; then printf "%4d : %s\n" $n "$dir"; fi; done |
Find all files/directories under '/etc' directory tree that have been modified after '/etc/motd' | find /etc -newer /etc/motd |
run ls command on files found | find . -name "*.pl" -exec ls -ld {} \; |
Filters only directories from long file listing of the current directory | ls -l --color=always "$@" | egrep --color=never '^d|^[[:digit:]]+ d' |
Extract, sort and print only group names from /etc/group. | cut -d: -f1 /etc/group | sort |
Save "$N" number of '.' characters in variable "myvar" | myvar=`seq 1 $N | sed 's/.*/./' | tr -d '\n'` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.