nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
show all files in the entire file system
|
find / -print0 | perl -ln0e 'print "found $_" if -p'
|
remove all core files in the file system
|
find / -name "*.core" -print -exec rm {} \;
|
Search the *.code files from the current directory tree for string 'pattern'
|
find . -name '*.code' -print0 | xargs -0 grep -H 'pattern'
|
Print the list of all regular files in the current directory and below
|
find . -type f
|
change the extension of all the ".abc" files in the folder "/the/path" to ".edefg" and do not change in the sub directories
|
find /the/path -depth -type f -name "*.abc" -exec sh -c 'mv "$1" "$/$.edefg"' _ {} \;
|
find for a word in all the regular files in the current directory
|
find . -type f -print | xargs grep -li 'bin/ksh'
|
Find all files starting from the current directory that match regular expression '.*Message.*\.java'
|
find . -print | grep '.*Message.*\.java'
|
Recursively lists all files in a current folder in long format, sorting by modification time.
|
ls -ldt $
|
Modify and rewrite 'file' replacing the first instance of "foo" on each line with "bar"
|
sed -i 's/foo/bar/' file
|
Find all *.sql file that are not newer than $oldest_to_keep excluding the $oldest_to_keep file
|
find . -name \*.sql -not -samefile $oldest_to_keep -not -newer $oldest_to_keep
|
Find files/directories under '/usr' directory tree that are newer than /tmp/stamp$$ by modification time
|
find /usr -newer /tmp/stamp$$
|
Unsets GNUPLOT_DRIVER_DIR variable.
|
unset GNUPLOT_DRIVER_DIR
|
delete all empty files in the current directory
|
find . -empty -exec rm '{}' \;
|
Display the contents of "sample_0001.gz" with "lk=1&" removed
|
zcat sample_0001.gz | sed -e 's/lk=1&//g'
|
Check if content of all top-level *.txt files in the current directory contain only unique lines
|
cat *.txt | sort | sort -u -c
|
Search the current directory recursively for regular files last accessed 2 minutes ago
|
find . type -f -amin 2
|
Save the current date to 'DATE' variable
|
DATE=$
|
Print a hex dump byte to byte of the output of "printf Aa"
|
printf Aa | od -t x1
|
Create a directory named 'alpha_real' in the current directory
|
mkdir alpha_real
|
Find files matching pattern $2 in the $1 directory recursively and search them for text $3, where $1, $2, $3 are the command line arguments to the Bash script
|
find $1 -name "$2" -exec grep -Hn "$3" {} \;
|
delete all the text files from the current folder after user confirmation
|
find . -name "*.txt" -ok rm {} \;
|
Make directory "/tmp/foo"
|
mkdir /tmp/foo
|
change owner and group of the file "file" to user "user" and group "group"
|
chown user:group file ...
|
Save the current working directory to variable "CURRENT"
|
CURRENT=`pwd`
|
Search directory lpi104-6 for files with inode number 1988884
|
find lpi104-6 -inum 1988884
|
Print only group names from /etc/group.
|
cut -d: -f1 /etc/group
|
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}'
|
List all leaf directories under current directory
|
find . -type d -execdir sh -c 'test -z "$" && echo $PWD/{}' \;
|
change owner and group of the file uid_demo to user and group root
|
sudo chown root:root uid_demo
|
List all aliencoders.[0-9]+ files/directories under /home/jassi/ directory
|
find /home/jassi/ -name "aliencoders.[0-9]+" -exec ls -lrt {} + | awk '{print $9}'
|
Search the current directory tree for directories
|
find $PWD -type d
|
Find all files/directories that belong to the group 'staff' under '/usr' directory tree
|
find /usr -group staff
|
Create a compressed archive of "/home" and split the contents into files with at most 4000 MiB each and use prefix "/media/DRIVENAME/BACKUPNAME.tgz"
|
tar --one-file-system -czv /home | split -b 4000m - /media/DRIVENAME/BACKUPNAME.tgz
|
Remove all files and directories in the current directory by answering with "y" to all prompts
|
yes | /bin/rm -i *
|
find all the files that have been changed today
|
find . -ctime 0 -type f
|
search for files in the current folder ending with ".au"
|
find -type f -name '*.au'
|
Find all files/directories with 777 permission under '/apps/audit' and strip write permission for 'other' from them
|
find /apps/audit -perm -7 -print | xargs chmod o‑w
|
Find all *.htm files under current directory and print the changed names by appending 3 levels of parent directory names at the beginning and modifying the actual name to dd-nnn format
|
find -type f -name "*.htm" | awk -F'[/]' 'BEGIN{OFS="-"}{ gsub ;print $1,$2, substr,substr,substr }'
|
Removes all empty folders with modification time more that 10 minutes ago from $homeDirData folder.
|
find $homeDirData -type d -mmin +10 -print0 | xargs -0 rmdir
|
Search all *.c files from the current directory tree for "hogehoge"
|
find . -name \*.c -exec grep hogehoge {} \;
|
Find *.tex files in the current directory tree that contain text "documentclass"
|
find . -type f -name *.tex -print0 | xargs -0 grep -l 'documentclass'
|
SSH into host "server" as user "user"
|
ssh user@server
|
Copies file 'file.txt' to each top-level directory in the current directory.
|
ls -d */ | xargs -iA cp file.txt A
|
find the path of a specfic video file in the current directory
|
find . -name foo.mp4 | sed 's|/[^/]*$||'
|
Print the list of all directories in the /myfiles directory tree
|
find /myfiles -type d
|
Save the list of files containing string `ExtJSLogin' to files.txt excluding change-app-name.sh
|
find . -type f -exec grep -l 'ExtJSLogin' {} \; | grep -v 'change-app-name.sh' > files.txt
|
Find all *.py files/directories under current directory
|
find . -name *.py
|
display a long listing of the files in current folder which have been modified in the last 60 minutes
|
find . -mmin -60 |xargs ls -l
|
Expands `whoami` as current user name, and adds resulted path to the directory stack.
|
pushd /home/`whoami`/Pictures
|
Find files named 'core' in or below the directory /tmp and delete them
|
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
|
display all the files in the entire file system which have set uid bit set.
|
find / -perm -u+s -print
|
find all directories with the name like "????-??-??" and which have not been modified in the last 24 hours in the folder /volume1/photo/ipcam and send them as input to the script in the exec section
|
find /volume1/photo/ipcam -maxdepth 1 -type d -name "????-??-??" -mtime +0 -exec sh -c 'echo /home/pi/Dropbox-Uploader/dropbox_uploader.sh move /ipcam/$ /ipcam/archive' \;
|
find all files under the current directory, redirecting error messages to the output and filtering any lines containing the text "Permission denied", writing the remaining output to some_file
|
find . 2>&1 | grep -v 'Permission denied' > some_file
|
list all regular files which path is not dir1 or dir2
|
find dir -not \( -path "dir1" -o -path "dir2" -prune \) -type f
|
find all the config(.conf files) files in the folder /home/pat
|
find /home/pat -iname "*.conf"
|
display all normal/regular files in current directory
|
find . -type f
|
Displays line count in 'filename' every 2 seconds.
|
watch wc -l <filename>
|
search for the file chapter1 in the folder /work
|
find /work -name chapter1
|
Find all the regular files in $DIR directory tree which have not been modified in the last 15 days and delete them
|
find "$DIR" -type f -mtime +15 -exec rm {} \;
|
Prints name of temporary file but doesn`t create nothing.
|
mktemp -u
|
Forward port 16186 on hello.com to 8888 on localhost using private key "privatekeystuffdis88s8dsf8h8hsd8fh8d" for login
|
ssh -N -i <(echo "privatekeystuffdis88s8dsf8h8hsd8fh8d") -R 16186:localhost:8888 hello.com
|
Move all files from the `sourceDir' directory to the `destDir' directory
|
find sourceDir -mindepth 1 -maxdepth 1 -print0 | xargs -0 mv --target-directory=destDir
|
display all files in the current folder which do not match the regular expression
|
find . -not -regex ".*test.*"
|
Display an infinite number of lines consisting of "y", until the user presses the Q key.
|
yes | cat | more
|
Changes group ownership of 'public' and 'private' to 'god'.
|
chgrp god public private
|
Find recursively all files in the "." directory tree whose names end with ".class" and delete them
|
find . -type f -name "*.class" -exec rm -vf {} \;
|
Finds total lines count of few types of files in a current folder and subfolders.
|
( find . \ -print0 | xargs -0 cat ) | wc -l
|
Print each ".txt" file in the current directory
|
paste --delimiter=\\n --serial *.txt
|
Replace "inputfile" with a sorted unique list of its contents
|
sort inputfile | uniq | sort -o inputfile
|
Display a long listing of all directories under '/nas' directory tree
|
find /nas -type d -ls
|
Remove everything in a current folder prompting user on each action.
|
rm -ri *
|
Find all files/directories under current directory that match the case insensitive regex ./\(EA\|FS\)_.*
|
find . -iregex './\(EA\|FS\)_.*'
|
Run `command' passing the files from the current directory tree as arguments
|
find . -print|xargs command
|
List all leaf directories (directories which don't contain any sub-directory) under current directory
|
find -depth -type d |sed 'h; :b; $b; N; /^\(.*\)\/.*\n\1$/ { g; bb }; $ {x; b}; P; D'
|
Limit each line in "your_file" to 80 characters and view via "more"
|
fold -80 your_file | more
|
Rename all .html files to .txt
|
rename 's/\.html$/\.txt/' *.html
|
Remove all files matching the pattern *[+{;"\\=?~()<>&*|$ ]* under current directory
|
find . -name '*[+{;"\\=?~()<>&*|$ ]*' -exec rm -f '{}' \;
|
Prints day of first Tuesday in a month.
|
cal | awk 'NR==2 {for (i=1;i<=NF;i++) {sub(/ /,"",$i);a[$i]=i}} NR>2 {if ($a["Tu"]~/[0-9]/) {printf "%02d\n",$a["Tu"];exit}}' FIELDWIDTHS="3 3 3 3 3 3 3 3"
|
Find all files named "file.ext" within the current folder and print the path where each one is located
|
find `pwd` -name "file.ext" -exec echo $(dirname {}) \;
|
Return the list of files named "filename" that are 50 megabytes or larger
|
find / -size +50M -iname "filename"
|
List screen IDs
|
screen -r
|
Find all files of the user with UID=1000
|
find -user 1000
|
Creates temporary folder and saves path to it in a 'tempd' variable.
|
tempd=`mktemp -d`
|
Prints long listing of the current directory and top-level directories within, sorted from oldest to newest, with appended indicators.
|
$ ls -Fltr *
|
search for a word in all the php files in the current folder and display the matching lines.
|
find . -name \*.php -type f -print0 | xargs -0 -n1 grep -Hn '$test'
|
Forcibly create symbolic links in target directory "~/staging" for all files located in directory "~/mirror"
|
ln --force --target-directory=~/staging ~/mirror/*
|
Calculate the md5 sum of the sorted list of md5 sums of all ".py" files under "/path/to/dir/"
|
find /path/to/dir/ -type f -name *.py -exec md5sum {} + | awk '{print $1}' | sort | md5sum
|
Remove all regular files under and below directory "$DIR" that were last accessed more than 5 days ago
|
find "$DIR" -type f -atime +5 -exec rm {} \;
|
Save IP addresses of the host name in variable "ip"
|
ip=$
|
find regular files under the current directory, whose name ends in .mbox, piping the output to a while loop that renames each file, to the same name without .mbox at the end
|
find . -type f -wholename \*.mbox -print0 | \ while read I ; do mv $I $ ; done ;
|
List all *.txt files/directories under /etc
|
find /etc -name "*.txt" -ls
|
Prints folder where current script is located
|
echo "dirname: `dirname $0`"
|
Redirects output of 'time' built-in function and prints only real-time statistic.
|
{ time find / &>/dev/null; } 2>&1 | grep real
|
Find *.NEF files under current directory and take only the filename without extension and run other commands on this file name.
|
find . -name "*.NEF" -exec basename \{\} .NEF \; | xargs> -i sh -c 'dcraw -w -c $0.NEF | convert - -resize 25% $0.jpg'
|
Move all Emacs backup files from the current directory tree to ~/backups/
|
find . -name '*~' -print 0 | xargs -0 -I % cp % ~/backups
|
Find root's files in the current directory tree
|
find ./ -user root
|
Treat references to unset variables as errors
|
set -o nounset
|
Reversibly sorts content of the '${TMP}/${SCRIPT_NAME}.kb' file, comparing human readable numbers in file strings.
|
cat ${TMP}/${SCRIPT_NAME}.kb|sort -rh;
|
Print "found" if "blah" contains the hex byte string "\xCA\xFE\xBA\xBE"
|
cat blah | perl -en '/\xCA\xFE\xBA\xBE/ && print "found"'
|
Remove all \*~ files under dir
|
find dir -name \\*~ -exec rm {} +
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.