nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Find a used disk space of a target directory and files inside of it
du -h your_directory
Find all regular files whose names do not end in "*.html"
find . -type f -not -name "*.html"
long list al the files in the current directory which have read permission to the group
find . -perm -g=r -type f -exec ls -l {} \;
Remove all *.swp files under current directory
find . -name "*.swp"|xargs rm
List all defined bash functions
set | egrep '^[^[:space:]]+ [][[:space:]]*$' | sed -r -e 's/ [][[:space:]]*$//'
Change owner of "folder" to "user_name"
chown user_name folder
Print first 11 characters from $line, print a tab, print the md5 sum of the file specified by the 13th and onward characters from $line and print a null character at end without a trailing new line
echo -en "${line:0:11}" "\t" $(md5sum "${line:12}") "\0"
search for the file, filename.txt in the folder /home
find /home -name filename.txt
Find files modified between 6 and 9 minutes ago
find . -mmin +5 -mmin -10
replaces the last occurrence of 'a' with 'c' in file
tac file | awk '/a/ && !seen {sub; seen=1} 1' | tac
Search all regular files in the current directory tree for "example"
find -type f -print0 | xargs -r0 grep -F 'example'
Start program 'scriptname' with an empty environment.
env - scriptname
Get A record for domain $domain
dig -t A $domain
Force create a symbolic link named "$pdir" to "$pluginpath" with verbose output
sudo ln --symbolic --verbose --force "$pluginpath" "$pdir"
Removes all empty folders under path '/foo/bar' and the path itself.
find /foo/bar -type d -depth -exec rmdir -p {} +
find Texinfo source files in /usr/local/doc
find /usr/local/doc -name '*.texi'
Split "file.tar.gz" into files of size 1024 MB
split -b 1024m file.tar.gz
Decompresses file.
bzip2 -d /tmp/itunes20140618.tbz
Search the current directory recursively for files last modified within the past 24 hours
find . -mtime 0
find all the files in the folder "/usr/app/etl/01/OTH/log/tra" which have been modified in the last 240 hours excluding hidden files and those with the name "/usr/app/etl/01/CLE/par/files_to_skip.par"
find /usr/app/etl/01/OTH/log/tra -type f ! -name ".*" -mtime -10 | egrep -vf /usr/app/etl/01/CLE/par/files_to_skip.par
Find all files/directories under current directory that match the case insensitive glob pattern {EA,FS}_*
find . -iname "{EA,FS}_*"
Decompress and unarchive "hello-0.2.tar.gz"
gzip -dc hello-0.2.tar.gz | tar -xf -
Find files that are orphaned
find -nouser
Save the absolute path of "$path" to variable "full_path"
full_path=`readlink -fn -- $path`
Compress all files in the "$FILE" directory tree that were last modified 30 days ago and have not already been compressed with gzip
find $FILE -type f -not -name '*.gz' -mtime 30 -exec gzip {} \;
Move "file1", "file2", "..." to "target" directory
mv -t target file1 file2 ...
display all the files in the file system which do not belong to the user "wnj" and which are modified before the file "ttt"
find / \! \( -newer ttt -user wnj \) -print
List all files under current directory that are greater than 10MB in size
find . -size +10M -exec ls -ld {} \;
search for word linux in all the regular/normal files in the folder mail.
find ~/mail -type f | xargs grep "Linux"
Search the files of the current directory tree for string "searched-string"
find . | xargs grep "searched-string"
Find all files/directories under current directory that match the case insensitive extended regex .*/_.*
find -E . -iregex '.*/_.*'
Mount a read only ntfs filesystem
mount -t ntfs
Find all the Sticky Bit set files in entire file system whose permission are 551
find / -perm 0551
Print the list of files and directories of the /etc directory
find /etc/. ! -name . -prune
Executes 'sleep 10' in a subshell created by a pipeline of built-in function 'true'.
true | sleep 10
Print environment variable "IFS" and its value
set | grep ^IFS=
Find all files with the extension jpg regardless of case
find . -type f -iname '*.jpg' -print0
Use awk command 'FNR==NR { array[$1,$2]=$8; next } in array { print $0 ";" array[$1,$2] }' on compressed files "input1.vcf.gz" and "input2.vcf.gz"
gzip -dc input1.vcf.gz input2.vcf.gz | awk 'FNR==NR { array[$1,$2]=$8; next } in array { print $0 ";" array[$1,$2] }'
Print all files/directories under ... directory by terminating their paths with a null character
find ... -print0
Print login information of all users except the first two and replace all instances of " " with ", "
who | awk '{ if (NR!=1 && NR!=2) {print} }' | sed -e 's/ /, /g'
Add "new." to the beginning of the name of "original.filename", renaming it to "new.original.filename".
rename 's/^/new./' original.filename
display all the files in the folder /home which have the setuid bit enabled
find /home -perm /u=s
Find files with group write permission and remove the permission
find . -perm -20 -exec chmod g-w {} ;
find all the files in the current directory that have the extension "bar" and donot search in the subdirecotries directories.
find . -name *.bar -maxdepth 2 -print
Append the parent directory name with a space in all 'text.txt' files in all sub directories of current directory
find . -name text.txt | sed 's|.*/\(.*\)/.*|sed -i "s@^@\1 @" & |' | sh
Find all files/directories under /home/foo/public_html/ that were modified less than 60 minutes ago
grep ! error_log | find /home/foo/public_html/ -mmin -60
Execute /usr/bin/find with $* arguments
/usr/bin/find $*
Search the home directory for files accessed more than 10 days ago
find ~/ -atime +10
Print content of 'a' file, showing all non-printing characters including TAB characters, and displaying $ at the end of each line.
cat -vet a
List all *.java files/directories under /home/bluher with their full paths
find /home/bluher -name \*.java
Find all files under current directory and set their permission to 775
find -type f | xargs chmod 775
Print a 2 byte decimal integer from "/dev/random"
od -An -N2 -i /dev/random
Removes 55, adds a 10-digit line number, and rearranges the date for each line in "input" on OSX
nl -nrz -w10 -s\; input | sed -E 's/55//; s/([0-9]{2})-([0-9]{2})-([0-9]{4})/\3\2\1/'
list files that the user does not have permissions to read, do not try to descend into directories that cannot be read.
find . ! -readable -prune
Find all .txt files in the /home/user directory tree and copy them to /home/backup
find /home/user -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents
search for the word "search-pattern" in all the regular/normal files in the current folder and display the matched file name
find . -type f | xargs grep -l "search-pattern"
Prints full path to files with dot in name in a current folder.
ls -d -1 $PWD/*.*
Move all files and directories in the current directory to "/foo"
mv * /foo
Print all lines of "seq 10" except the last 3
seq 10 | tac | sed '1,3d' | tac
Counts lines of all *.txt files in a current folder.
cat *.txt | wc -l
Force delete all files in the temp folder which have not been accesses in the last 240 hours
find /tmp/* -atime +10 -exec rm -f {} \;
Print the contents of "somefile" as input to "splitter 16224-16482"
cat somefile | splitter 16224-16482
Find all files/directories under 'my key phrase' directory
find 'my key phrase'
Print "on" to standard output and to files matching "/sys/bus/usb/devices/usb*/power/level"
echo "on" | tee /sys/bus/usb/devices/usb*/power/level
Print summary of new/missing files, and which files differ between dir_one and dir_two, sorted alphabetically.
diff -qr dir_one dir_two | sort
Removes 55, adds a 10-digit line number, and rearranges the date for each line in "input" on OSX
nl -nrz -w10 -s\; input | sed -E 's/55//; s/--/\3\2\1/'
Recursively remove all "*.txt" files and answer "n" to any prompt
yes n | rm -r *.txt
change the owner of all the files in the current directory
find . -exec chown myuser:a-common-group-name {} +
Remove all regular files from the current directory tree whose names do not end with "ignore1" or "ignore2"
find . -type f -not -name '*ignore1' -o -not -name '*ignore2' | xargs rm
Search for 'birthday' in all regular files under ~/Documents directory tree and show only the filenames
find ~/Documents -type f -print0 | xargs -0 grep -il birthday
Delete all files/directories under current directory
find -delete
Search current directory for any directory named "config" and go to first match found.
cd "$"
Find all files/directories with 755 permission under current directory tree
find ./ -perm 755
Decompresses file 'xac.bz2', redirecting output to standard out.
bzip2 -dc xac.bz2
change the ownership of all the files in the file system from edwarda to earnestc
find / -user edwarda -print | xargs chown earnestc
Find all directories under /var/www directory and set their permission to 755
sudo find /var/www -type d -print0 | xargs -0 chmod 755
List all cron jobs which contain "word".
crontab -l | grep 'word'
Split "randn20M.csv" into files of at most 5000000 lines each with prefix "_tmp"
split -l5000000 randn20M.csv '_tmp';
Redirects output of 'time' built-in function and prints only real-time statistic.
{ time ls -l >/dev/null; } |& grep real
Prints listing of a root folder including hidden files, and saves output to 'output.file'.
ls -a | tee output.file
get all files in a current directory modified in the last 7 days
find . -mtime -7 -print0 | xargs -0 tar -rf /foo/archive.tar
Search for all files newer than file /tmp/t1 but not newer than file /tmp/t2
find / -newer /tmp/t1 -and -not -newer /tmp/t2
Copy entire directory structure from dir1 as a subdirectory of dir2, omitting empty directories, special files and any directory named "exclude".
mkdir dir2; find dir1 \ -not -wholename '*/exclude/*' -exec cp -P --parents '{}' dir2/ \;
List all aliencoders.[0-9]+ files/directories under /home/jassi/ directory
find /home/jassi/ -name "aliencoders.[0-9]+" -exec ls -lrt {} + | awk '{print $9}'
find all the files in the current folder which have set guid bit on and list the top 10 files.
find . -perm /g+s | head
find all files in the current folder which have not been accessed in the last 7 days or which are bigger than 20KB
find . -atime +7 -o -size +`expr 10 \* 1024 \* 2` -print
Replace all negative numbers in the 3rd comma-separated column of inputfile by the number notated in parenthesis instead of with a minus sign.
awk -F, 'BEGIN {OFS = ","} {gsub("-", "(" substr ")", $3); print}' inputfile
Find all HTML files starting with letter 'a' in the current directory and below ignoring the case
find . -iname a\*.html
searching for all files with the extension mp3
find / -name *.mp3
change the extension of all the files in the current folder to html excluding those html files and those which are present in another disk partition
find . -xtype f \! -iname *.html -exec mv -iv "{}" "{}.html" \;
delete all the core files in the folder /prog which are bigger than 1KB
find /prog -type f -size +1000 -print -name core -exec rm {} \;
Save absolute path of "$path" whose parents exist to variable "abspath"
abspath=$
Print lines 15967 to 16224 in file "dump.txt"
cat dump.txt | head -16224 | tail -258
Find all directories under /fss/fin
find /fss/fin -type d
Change the user to daisy for directories and subdirectories owned by harry
find . -type d -user harry -exec chown daisy {} \;
Find all files/directories named 'query' under current directory tree
find -name "query"
Search all the .c and .h files in the current directory tree for "expr"
find -name '*.[ch]' | xargs grep -E 'expr'
Print directories in the the current directory as a list with no report information
tree -d -L 1 -i --noreport
Calculate the md5 sum of the contents of all files sorted in directory tree "/path"
find /path -type f | sort -u | xargs cat | md5sum
List all ~/bin/FilesDvorak/.* (non-recursive) and ~/.PAST_RC_files/.* (recursive) files/directories and take common entries between these two lists
comm -12 <(find ~/bin/FilesDvorak/.* -maxdepth 0) <(find ~/.PAST_RC_files/.*)