nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Search the current directory tree for regular files last changed more than 14 days ago | find -type f -ctime +14 |
Counts all files in a current folder and subfolders. | find -type f -exec printf '\n' \; | wc -l |
Add line numbers to each non-blank line in "file" starting with number 1000001 | nl -v1000001 file |
find all the files in the current directory that have the word "bash" in their name | find . -name "*bash*" |
Find all files under $dir directory | find "$dir" -type f |
Execute "killall -USR1 dd" every minute | watch -n 60 killall -USR1 dd |
Find all files/directories under current directory that were accessed 30 minutes ago | find -amin 30 |
List every directory under current directory with their child executable files | find . -type d | sort | xargs -n1 -I{} bash -c "find {} -type f -maxdepth 1 -executable | sort -r" |
display all the jars in the current folder | find . -iname '*.jar' |
Find empty files in the test directory | find test -empty |
Display file type information for all instances of "file" in the current PATH. | which file | xargs file |
Find all files/directories named 'articles.jpg' under current directory tree | find . -name "articles.jpg" |
Copy a whole directory tree skipping files residing on other files systems to destination_dir | find ./ -mount -depth -print | cpio -pdm /destination_dir |
Prints calendar of April of 2012, and redirects output to 't' file and 'more' pager tool. | cal April 2012 | tee t | more |
Number each line in "foobar" as right-justified zero padded to a width of 9 | nl -nrz -w9 foobar |
Find all *.rb and *.py files/directories under current directory | find . -name "*.rb" -or -name "*.py" |
display all the normal/regular files in a directory | find $dir -type f -name $name -print |
Prints long listing of content in a root folder, including hidden files, with human-readable sizes, and stores output to '/root/test.out' file. | ls -hal /root/ | sudo tee /root/test.out |
Print the file type of the full path of "rename" | file $(readlink -f $) |
Merge data in file1 and file2 where second field is common in both files | join -j2 < < |
Find all .rpm files and change their permissions to 755 | find / -name *.rpm -exec chmod 755 '{}' \; |
Creates temporary file by template provided in option '-t'. | mktemp -t identifier.XXXXXXXXXX |
Move all *.pdf.marker files and their corresponding *.pdf files under ${INPUT_LOCATION} to ${OUTPUT_LOCATION} | find "${INPUT_LOCATION}" -name '*.pdf.marker' | xargs -i bash -cx 'pdf=`dirname {}`/`basename {} .marker`;[ -e "$pdf" ]&&{ mv {} "$pdf" "$0";}' "${OUTPUT_LOCATION}" |
Write "Australia/Adelaide" to standard output and to "/etc/timezone" | echo "Australia/Adelaide" | sudo tee /etc/timezone |
find all c & c++ files in the current directory and save output names to another file | find . -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" > cscope.files |
Delete all empty directories and directories that contain only empty directories under current directory | find -type d -empty -exec rmdir -vp --ignore-fail-on-non-empty {} + |
find all the text files in the current folder and do not search in the sub directories | find -maxdepth 1 -iname "*.txt" |
searches through the root filesystem ("/") for the file named Chapter1, and prints the location | find / -name Chapter1 -type f -print |
Search for the regex expaned by the variable $SEARCH in all regular files under $DIR directory tree | find "$DIR" -type f -exec grep "$SEARCH" {} \; |
Sources script incl.sh in the folder where current script is located. | source $(dirname $0)/incl.sh |
find in $HOME files ending in "txt" and do nothing with them, or files ending in "html" and list them null separated. | find $HOME -name \*txt -o -name \*html -print0 |
Takes folder path from string '/path/to/copy/file/to/is/very/deep/there' and created it with all parents. | mkdir -p `dirname /path/to/copy/file/to/is/very/deep/there` \ |
Search the /path/to/directory tree for regular files modified 61 days ago and then remove them | find /path/to/directory -type f -mtime 61 -exec rm -f {} \; |
Print the pathnames of all files from the /tmp/dir1 directory tree | find /tmp/dir1 -exec echo {} \; |
find & Substitute Only When the Line Matches with the Pattern Using sed | find . -type f -name "*.txt" -exec sed '/\-/s /\-.*//g' {} \; |
Show the list of files modified less than a minute ago | find / -mmin -1 -print |
Search directory trees foo and bar for .java files | find foo bar -name "*.java" |
Search for "1234567890" in every gzip file modified between 8:00 and 9:00 on 2014-04-30 | find . -newermt '2014-04-30 08:00:00' -not -newermt '2014-04-30 09:00:00' |xargs gunzip -c | grep 1234567890 |
Append all regular files modified in the last 24 hours to the "$archive.tar" tar archive | find . -mtime -1 -type f -exec tar rvf "$archive.tar" '{}' \; |
list PID of a group leader | jobs -lp |
List and remove all regular files named "core" that are larger than 500KB | find /prog -type f -size +1000 -print -name core -exec rm {} \; |
display the three smallest files by size in a folder. | find /etc/ -type f -exec ls -s {} + | sort -n | head -3 |
Print a sorted list of the extensions of the regular files from the current directory tree | find . -type f -name "*.*" | awk -F. '{print $NF}' | sort -u |
Make directory "tata" | mkdir tata |
Recursively search through all files in all directories for any lines containing "pattern" and whose second word is not "Binary". | grep -Ri "pattern" * | awk '{if print $0}' |
Find all files/directories named orm.properties under /eserver6/share/system/config/cluster directory | find /eserver6/share/system/config/cluster -name "orm.properties" |
Print the input "hello world" followed by a swap of the first two awk fields | echo hello world | tee > |
Go to directory pointed by last element of array "dirs" in bash version 4.2 | cd "${dirs[-1]}" |
find foo, Foo, FOo, FOO, etc. | find . -iname foo |
Search for "YOURSTRING" in all files under current directory | grep YOURSTRING `find .` |
Search for directories that contain the phrase "foo" but do not end in ".bar" | find . -name '*foo*' ! -name '*.bar' -type d -print |
Print the characters in $b that match with any character in $a without printing any newline | echo "$b" | grep -o "[$a]" | tr -d '\n' |
Changes group ownership of 'logdir' to 'loggroup'. | chgrp loggroup logdir |
display the commands to force delete all jpg files in current directory which are less than 50KB and do not search in the sub directories | find . -maxdepth 1 -name "*.jpg" -size -50k | xargs echo rm -f |
Find all files/directories under current directory that were modified later than /reference/file | find . -newer /reference/file |
Find all *.mov files under current directory | find . -name "*.mov" |
Write every two lines in "infile" on a single line separated by a space | cat infile | paste -sd ' \n' |
search for the directory with the name aa in the current folder | find . -type d -name aa |
Copy all .txt files from the dir/ directory tree along with their parent directories hierarchy | find dir/ -name '*.txt' | xargs cp -a --target-directory=dir_txt/ --parents |
Remove the path $1 from the PATH environment variable | PATH=$(echo $PATH | tr ":" "\n" | grep -v $1 | tr "\n" ":") |
Counts lines in file $file and prints number only. | wc -l $file | awk '{print $1}'; |
Copy all files in "/var/spool/mail" to "/home/username/mail" preserving the directory hierarchy and modification times | find /var/spool/mail -type f | cpio -pvdmB /home/username/mail |
Find all directories with 755 permission and change the permission to 700 | find . -type d -perm 755 -exec chmod 700 {} \; |
create directory /cpuset | mkdir /cpuset |
Find all files in /var/www/html/zip/data/*/*/*/*/* that are older than 90 days and print their parent directory paths | find /var/www/html/zip/data/*/*/*/*/* -type f -mtime +90 | sed 's|/[^/]*$||' |
Find recursively all regular .txt files in the current directory tree except README.txt | find . -type f -name "*.txt" ! -name README.txt -print |
Change the ownership to eva for all files/directories that belong to the user 'george' in the entire file system without traversing to other devices/partitions | find -x / -user george -print0 | xargs -0 chown eva |
Archive "/source" and all files under "folder/" to "/dstfolder/" on host "remoteserver" as user "user" without copying files that already exist | rsync -avz --ignore-existing /source folder/* user@remoteserver:/dstfolder/ |
find foo, Foo, FOo, FOO, etc. | find . -iname foo |
Find '.java' files with checksum 0bee89b07a248e27c83fc3d5951213c1 in the current directory | md5sum *.java | grep 0bee89b07a248e27c83fc3d5951213c1 |
Delete files under $LOCATION that match $REQUIRED_FILES in their names and were modified more than 1 day ago | find $LOCATION -name $REQUIRED_FILES -type f -mtime +1 -delete |
Delete all files/directories with node number $inum under current directory tree | find . -inum $inum -exec rm {} \ |
Print "huge-file.log" starting at line 1000001 | tail -n +1000001 huge-file.log |
Count all the lines of code in all php files in current directory recursively | find . -name "*.php" | xargs grep -v -c '^$' | awk 'BEGIN {FS=":"} { $cnt = $cnt + $2} END {print $cnt}' |
Run commands "df -k;uname -a" on server "192.168.79.134" | echo "df -k;uname -a" | ssh 192.168.79.134 |
Use "vagrant-ssh" as the config file and ssh into "default" host | ssh -F vagrant-ssh default |
Find files on the system whose names begin with either x or X | find / -name "[Xx]*" |
Find all image.pdf files/directories under ./polkadots | find ./polkadots -name 'image.pdf' |
Search the /home/weedly directory tree for regular files named myfile | find /home/weedly -name myfile -type f -print |
Show filename and filetype description of all PHP files in all directories contained in current directory whose name or filetype description includes "UTF" | file */*.php | grep UTF |
Find all regular files in current directory and /home/www directory | find * /home/www -type f |
Recursively copy all directories in "/path/to/source" to "/path/to/dest/" preserving directory hierarchy | find /path/to/source -type d | cpio -pd /path/to/dest/ |
Find all files/directories in entire file system more than 700 Megabytes | find / -size +700M |
Counts all non-blank lines in the $i file. | sed '/^\s*$/d' $i | wc -l ## skip blank lines |
Print information of the process running the current script as the current user | ps -ef | grep $0 | grep $(whoami) |
display long listing of all the empty files in the current folder | find . -empty -exec ls -l {} \; |
Measure the disk space taken up by all TXT files in the current directory tree | find . -iname "*.txt" -exec du -b {} + | awk '{total += $1} END {print total}' |
Find all files/directories named 'document' in the root filesystem partition | find / -xdev -name document -print |
show all the ".flac" files in the current folder and do not search in the sub directories | find . -maxdepth 1 -type f -name '*.flac' |
Locate world-writable files and directories on the system | find / -path /proc -prune -o -perm -2 ! -type l -ls |
Copy directory hierarchy from "./<SOURCE_DIR>/" to "<DEST_DIR>" | find ./<SOURCE_DIR>/ -type d | sed 's/\.\/<SOURCE_DIR>//g' | xargs -I {} mkdir -p <DEST_DIR>"/{}" |
Set variable 'rav' to the contents of 'var' spelled backwards. | rav=$ |
Copy file 'src' to 'dest', except if 'dest' already exists. | cp -n src dest |
Send 4 ping requests to host "google.comz", displaying only the summary info after the last request completed. | ping -c 4 -q google.comz |
Find all *.log files under path/ | find path/ -name "*.log" |
find all the directories in the current folder which have been modified in 24 hours and move them to the folder /path/to/target-dir | find . -type d -mtime 0 -exec mv {} /path/to/target-dir \; |
Find all files under current directory and upload them to https://PATH_TO_NEXUS/ | find . -type f -exec curl --user user:pass --ftp-create-dirs -T {} https://PATH_TO_NEXUS/{} \; |
display all the files in the current folder that end with ".ksh" | find . -name "*.ksh" -prune |
Save the current date to 'DATE' variable | DATE=$(echo `date`) |
Find files on the system accessed during the last 24 hours but not within the last hour | find / -atime -1 -amin +60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.