nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Perform white space safe deletion of files named core under /tmp
|
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
|
Output the specified path removing all containing directories and the .txt suffix, in this case "filename".
|
basename /path/to/dir/filename.txt .txt
|
create directory es if it is not exist and create direcoty LC_MESSAGES
|
mkdir -p es/LC_MESSAGES
|
Split "INPUT_FILE_NAME" into files of at most 500 MiB each with a numeric suffix of length 4 and prefix "input.part."
|
split -b 500M -d -a 4 INPUT_FILE_NAME input.part.
|
Prints current month calendar, without highlighting of a current date.
|
cal -h
|
find all the files in the root folder which have been modified in the last 24 hours and print them
|
find / -mtime -1 -print
|
Find all files/directories named file1 under current directory
|
find -name file1
|
Save the filename and hash of the md5 sum of "file" to bash array "md5"
|
md5=($)
|
Search file aaa from current direcoty downwards and print it .
|
find . -name aaa -print
|
Find with combine multiple search criterias , in this command serach files that begin with abc in there name and dont have .py extension .
|
find . -type f -name 'abc*' ! -name '*.py'
|
Find all *fstab* files under and below /etc
|
find /etc -name *fstab*
|
Find all directories under $x directory and set read-write-execute permission for owner and group and no permission for other for those directories
|
find ${x} -type d -exec chmod ug=rwx,o= '{}' \;
|
Search the files from the current directory tree for "foo"
|
find . -exec grep foo {} +
|
Change file permissions on all regular files within a directory
|
find /path/to/directory -type f -exec chmod 644 {} +
|
Save all directories under the current directory as a comma separated list in variable "FOLDERS"
|
FOLDERS=$
|
Recursively and forcibly removes $TMP folder with all content.
|
rm -fR "${TMP}/";
|
Search for $SEARCH in all regular files under $DIR directory tree and display the number of bytes of the matched output
|
find $DIR -type f -exec grep $SEARCH /dev/null {} \; | wc --bytes
|
find all the regular/normal files in the current folder which belong to the users with the user id's between 500 and 1000
|
find . -uid +500 -uid -1000 -type f
|
Find *.html files in the current directory tree that were modified less than 7 days ago
|
find . -mtime -7 -name "*.html" -print
|
Output the file name "file.txt' from the path "some/unknown/amount/of/sub/folder/file.txt"
|
basename "some/unknown/amount/of/sub/folder/file.txt"
|
Print 1 byte from "/dev/urandom" as a signed decimal value and no address radix
|
od -A n -t d -N 1 /dev/urandom
|
create a compressed archive "compressFileName.tar.gz" with verbose output
|
tar -zcvf compressFileName.tar.gz folderToCompress
|
List the current directory recursively ignoring the "dir1" subdirectory
|
find . -path ./dir1 -prune -o -print
|
Remove files modified at least five days ago in directory trees /path/to/files*
|
find /path/to/files* -mtime +5 -exec rm {} \;
|
Remove all files containing 'sample' (case insensitive) in their names under '/home/user/Series' directory tree
|
find /home/user/Series/ -iname '*sample*' -exec rm {} \;
|
Read the first line of "$sh_lock_file" into variable "sh_lock_lastPID"
|
read sh_lock_lastPID < $sh_lock_file
|
Find all files/directories under minimum 2 level down the current directory and set their permission to 700
|
find . -mindepth 2 | xargs chmod 700
|
Search for the case insensitive regex expanded by $2 in all files named $1 (to be expanded) under current directory
|
find . -name "$1" -type f -print0 | xargs -0 grep -i "$2"
|
display all regular/normal files in the current folder which are accessed in the last 7*24 hours
|
find . -type f -atime -7
|
display all the files in the current folder which have been modified in one hour ago
|
find . -newermt "1 hour ago"
|
display all files in the folder /usr and its sub directory(do not search beyond the sub directory)
|
find /usr -maxdepth 1 -print
|
Search the /etc/apache-perl directory tree for files newer than /etc/apache-perl/httpd.conf
|
find /etc/apache-perl -newer /etc/apache-perl/httpd.conf
|
Find files larger than 100MB in /var/www and exclude files with /download/ in their path from the output
|
find /var/www/ -type f -name "*" -size +100M -exec du -h '{}' \;|grep -v /download/
|
find regular file named foo.txt under root / directory.
|
find / -name foo.txt -type f
|
Read a line from standard input into variable "REPLY" with prompt "$1 ([y]es or [N]o): "
|
read -p "$1 ([y]es or [N]o): "
|
Search directory $CURR_DIR for regular files that were changed, accessed, or modified $FTIME days ago
|
find ${CURR_DIR} -type f \( -ctime ${FTIME} -o -atime ${FTIME} -o -mtime ${FTIME} \) -printf "./%P\n"
|
Find all files/directories under current directory with null character as the delimiter and then replace the null characters with :
|
find -print0 | tr "\0" ":"
|
search all undo files(ending with .undo) in the current folder and calculate the total size of them
|
find -name '*.undo' -exec wc -c {} + | tail -n 1 | cut -d' ' -f 1
|
Search for all files newer than file /tmp/t
|
find / -newer /tmp/t
|
Filters only directories from long file listing of the current directory
|
ls -l --color=always "$@" | grep --color=never '^d'
|
Prints information about user $euids currently on machine and its processes, without printing header.
|
w -h $euids
|
Replace spaces in file names with underscores for all files in the current directory tree
|
find -name "* *" -type f | rename 's/ /_/g'
|
Export variable "PS1" as the current username "@" the hostname
|
export PS1='$@$:'
|
find all the css files
|
find -name '*.css'
|
Find all files in the /home/ directory tree that were last modified less than 7 days ago
|
find /home -mtime -7
|
download contents from "http://www.example.com" using a proxy server
|
curl http://www.example.com --proxy http://125.119.175.48:8909
|
Find any file that has "disc" somewhere in its name in the current directory and all of its sub-directories.
|
find . -name *disc*
|
Recursively removes all files and folders named '.svn' in a current folder.
|
find . -name .svn | xargs rm -fr
|
Replace each newline in input "1\n2\n3\n4\n5" with a comma
|
echo "1\n2\n3\n4\n5" | paste -s -d, /dev/stdin
|
Delete and count files in $DIR_TO_CLEAN that are older than $DAYS_TO_SAVE days
|
find "$DIR_TO_CLEAN" -type f -mtime +$DAYS_TO_SAVE -print0 | awk -v RS='\0' -v ORS='\0' '{ print } END { print NR }' | xargs -0 rm
|
Find all files in the current directory tree whose names are ".DS_STORE"
|
find . -name ".DS_STORE"
|
SSH into user@server and run command ${SSH_COMMAND}
|
ssh user@server "${SSH_COMMAND}"
|
search for a word in all the files in the current directory
|
find . -type f -exec grep 'needle' {} \;
|
display all the normal/regular files in the directory FOLDER1
|
find FOLDER1 -type f -print0
|
Search my_folder recursively for text files containing "needle text"
|
find my_folder -type f -exec grep -l "needle text" {} \; -exec file {} \; | grep text
|
Print "yes" 4 times followed by 1 "no"
|
yes yes | sed -e 5s/yes/no/ -e 5q
|
find all the files in the current folder which have been modified after the file disk.log
|
find . -newer disk.log -print
|
Replace all spaces with underscores in file paths under current directory.
|
find -name "* *" -type f | rename 's/ /_/g'
|
Find all image.pdf files under ./polkadots
|
find ./polkadots -type f -name "image.pdf"
|
Print NS record for domain 'domain.' from 8.8.8.8 nameserver
|
dig @8.8.8.8 domain. ns
|
Copy the owner and group of "originalfile" to "newfile"
|
chown `stat -c %U originalfile`:`stat -c %G originalfile` newfile
|
Find all *.tar.gz files/directories under /directory/whatever which were modified more than $DAYS ago
|
find /directory/whatever -name '*.tar.gz' -mtime +$DAYS
|
run command "cd /home/$USERNAME/$PROJECT ; svn update" as user named as value of the variable $USERNAME
|
su -c "cd /home/$USERNAME/$PROJECT ; svn update" -m "$USERNAME"
|
Forcefully delete all files in the current directory
|
find . -name '*' | xargs rm
|
display the count of number html files in the current folder
|
find . -name "*.html" -print | xargs -l -i wc {}
|
find all the regular/normal files in the /path folder and delete them
|
find /path -type f -print0 | xargs -0 rm
|
display list of all the regular/normal files in the home folder which are bigger than 512 kb
|
find /home/ -type f -size +512k -exec ls -lh {} \;
|
Find all files under /home/mywebsite/public_html/sites/all/modules and set their permission to 640
|
find /home/mywebsite/public_html/sites/all/modules -type f -exec chmod 640 {} +
|
Counts the number of lines in each file in a git repository.
|
wc -l --files0-from=<
|
Make DNS lookup requests for domain list in file '/path/to/host-list.txt'
|
dig -f /path/to/host-list.txt
|
Dynamically defines tmux session name to attach to.
|
tmux attach -t "$"
|
Counts lines in each *.php file.
|
wc -l $(find . -name "*.php")
|
Force create a symbolic link without dereferencing named "$SYMLINK_PATH" to "$lastModified"
|
ln -nsf $lastModified $SYMLINK_PATH
|
Delete characters in columns 36 through 40 from the output of "finger"
|
finger | cut --complement -c36-40
|
Search for a pattern "can't" in all the files with the name "file-containing-can't" in the current directory tree
|
find . -name "file-containing-can't" -exec grep "can't" '{}' \; -print
|
Back up all *.txt files/directories in new files/directories with a .bak extension in their names under /etc directory
|
find /etc -name "*.txt" | xargs -I {} mv {} {}.bak
|
Replace "_" with newlines in "Testing\r\nTested_Hello_World" and display the named characters
|
echo -e "Testing\r\nTested_Hello_World" | awk -v RS="_" '{ print $0; }' | od -a
|
Search all files in the current directory tree that are named "whatever" for "you_search_for_it"
|
find -name whatever -exec grep --with-filename you_search_for_it {} \;
|
find all files in the current folder and search for a word in them.
|
find . -type f -exec grep "applicationX" {} \;
|
Print unique lines of "second-file-sorted.txt" compared to "first-file-sorted.txt"
|
comm -23 second-file-sorted.txt first-file-sorted.txt
|
Measure the disk space taken up by all *.txt files in the current directory tree
|
find . -name "*.txt" -print0 |xargs -0 du -ch | tail -n1
|
Find all files under current directory
|
find "`pwd`" -type f
|
Search the current directory tree for regular files omitting directory `omit-directory'
|
find . \( -name omit-directory -prune \) -o \( -type f -print \)
|
Find all files/directories that contain the string literal '$VERSION' in their names under current directory tree
|
find . -name '*$VERSION*'
|
list the files with a name ending with '.mp3' or '.jpg' and beginning with 'foo'
|
find . \ -name 'foo*' -print
|
Find files/directories under current directory that matches './projects/insanewebproject' in their paths
|
find -ipath './projects/insanewebproject'
|
Find all files under /mountpoint and below which have hard links
|
find /mountpoint -type f -links +1
|
Find all files in the current directory tree ignoring the ".git" directory
|
find . -type d -name '.git*' -prune -o -type f -print
|
Join columns in "file1" and "file2" if their first field matches and format the output as a table
|
join file1 file2 | column -t
|
Find all files under directory tree /path/to/dir whose permissions are not 644
|
find /path/to/dir ! -perm 0644
|
Gets domain name from dig reverse lookup.
|
$dig -x 8.8.8.8 | grep PTR | grep -o google.*
|
Search all files under and below /etc for IP addresses
|
find /etc -exec grep '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \;
|
change the permissions of all the directories in the current folder
|
find . -type d -exec chmod 2775 {} \;
|
Search for files/directories with the case insensitive pattern anaconda.* in /var/log directory and create an archive (file.tar) of the last file found
|
find /var/log/ -iname anaconda.* -exec tar -cvf file.tar {} \;
|
Rename all "thumbs" directories to "thumb" in the current directory and 1 level below
|
find . -maxdepth 2 -type d | sed 'p;s/thumbs/thumb/' | xargs -n2 mv
|
remove all the log files which have not been modified in the last 5 days
|
find /logs -type f -mtime +5 -exec rm {} \;
|
Change owner to "root" and group to "www-data" of "/foobar/test_file"
|
sudo chown root:www-data /foobar/test_file
|
display all the files in the kat folder
|
find kat -printf "%f\n"
|
Find files in the current directory whose names begin with "file" and remove them
|
find . -name file* -maxdepth 1 -exec rm {} \;
|
Find all files under $dir
|
find "$dir" -type f
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.