nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
display all the files in the current folder excluding search in the paths containing the folder having the word "mmm"
|
find . ! -path *mmm*
|
Find all the files that end with the extension “.java” in the current directoy tree
|
find . -name "*.java"
|
Find all *.txt files/directories under current directory
|
find . -name '*.txt'
|
search for MP3 files in the current folder and subfolders exclude dir1 AND dir2
|
find ! -path "dir1" ! -path "dir2" -iname "*.mp3"
|
Changes group ownership of '/home/www-user/php_user.sh' to 'www-data'.
|
chgrp www-data /home/www-user/php_user.sh
|
Request changing the passphrase of key file "private.key"
|
ssh-keygen -pf private.key
|
Find all files/directories named orm.properties under /eserver6 directory
|
find /eserver6 -name "orm.properties"
|
Change mode of all files ending with ".php" under the current folder to 755 and write the output to the console and "logfile.txt" file
|
find . -name '*.php' -exec chmod 755 {} \; | tee logfile.txt
|
Search directory tree $DIR for *.txt files
|
find "${DIR}" -name "*.txt"
|
Lists all files in a current folder, separating names with comma.
|
ls | xargs -I {} echo {}, | xargs echo
|
Change owner and group of "script.sh" to "root"
|
chown root:root script.sh
|
Recursively removes all files and folders like 'FILE-TO-FIND' from current folder.
|
find . -name "FILE-TO-FIND" -exec rm -rf {} \;
|
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 -exec rm {} \;
|
List all files/directories with spaces in their names under ~/Library directory
|
find ~/Library -name '* *' -exec ls {} \;
|
Prints process tree for the current process with ASCII line drawing characters.
|
pstree -A -s $$
|
Save absolute path of "/home/nohsib/dvc/../bop" in variable "absolute_path"
|
absolute_path=$
|
List regular files in current directory with read, write and execute permission for all users and also show the permissions
|
find . -type f -perm 777 -exec ls -l {} \;
|
Unzip "archive.tgz" and extract all archives excluding ones matching "apri/fls/filename"
|
zcat archive.tgz | tar -x --wildcards apri/fls/filename
|
find all directory list which have empty list in /tmp directory .
|
find /tmp -type d -empty
|
Changes group ownership of 'public' to 'pub'.
|
chgrp pub public
|
List directories under current directory
|
find . -type d
|
Find .txt files on the system whose size is greater than 12000 bytes
|
find / -name "*.txt" -size +12000c
|
Copy all files in the current directory except those containing 'Music' to '/target_directory'.
|
cp `ls | grep -v Music` /target_directory
|
Invoke a trusted X11 forwarding SSH connection with server "192.168.0.14" on port 222 as user "phil"
|
ssh -v -Y [email protected] -p 222
|
Find all empty directories under $somedir and copy /my/configfile into those directories
|
find "$somedir" -type d -empty -exec cp /my/configfile {} \;
|
Calculate the total disk usage for each ".jpg" file on the system and prepend the system host name to the output
|
find "$PWD" / -iname '*.jpg' -exec du -s {} + | sed "s/^/$: /"
|
Get a list of files and directories in the current directory tree
|
find . -print0 | xargs -0 echo
|
Search the current directory tree for *bash* files
|
find . -name "*bash*"
|
change permission of all the files in the entire file system which have the permissions 777.
|
find / -type f -perm 0777 -print -exec chmod 644 {} \;
|
Split "your_file" into files with at most 9 lines each
|
split -l9 your_file
|
Find all regular files under current directory tree whose names end with 'cache' or 'xml' or 'html'
|
find . -type f \( -name "*cache" -o -name "*xml" -o -name "*html" \)
|
Print only digits in variable "$name"
|
echo $name | tr -c -d 0-9
|
List all of the subdirectories in the current directory with no trailing slash.
|
ls -d */ | cut -f1 -d'/'
|
Print canonical filename of "/path/there/../../" even if it does not exist
|
readlink -m /path/there/../../
|
Prepend the reverse history number as negative values to the output of the history command with arguments "$@"
|
history "$@" | tac | nl | tac | sed 's/^\\/\1-\2/'
|
Remove the last 2 tab-separated fields of each line in file pointed to by filename
|
cat $filename | rev | cut -c 3- | rev
|
Prints yesterday's date information
|
date --date yesterday "+%a %d/%m/%Y"
|
Delete history entry at offset, defined in first argument of executed script
|
history -d "$1"
|
Copy all directories recursively from "source/" to "destination/" excluding all files
|
rsync -a -f"+ */" -f"- *" source/ destination/
|
Find all files under and below the current working directory with the word California in the file, and count the number of lines in the output
|
find . -type f -exec grep California {} \; -print | wc -l
|
Search the current directory tree for files last accessed more than 10 days ago
|
find . -atime +10
|
Do not immediately exit the shell if a command fails
|
set +e
|
Search for occurrences of string "main(" in the .c files from the current directory tree
|
find . -type f -name "*.c" -print -exec grep -s "main(" {} \;
|
Find sqlite3 databases in the current directory tree, execute query 'SELECT * FROM table WHERE column1="value"' on all of them, and search the result for "value"
|
find . -name "*.db" -type f | while read file ; do sqlite3 $file "SELECT * FROM table WHERE column1='value'" | grep value ; if [ $? -eq 0 ] ; then echo $file ; fi done
|
copy all java files from current folder to another folder
|
find . -name "*.java" -print0 | xargs -0 -J % cp % destinationFolder
|
search for the word "slrn" in all the files in the folder $HOME/html/andrews-corner
|
find $HOME/html/andrews-corner -exec grep -q 'slrn' '{}' \; -print
|
List all *.txt files/directories under /etc
|
find /etc -name "*.txt" | xargs ls -l
|
Recursively removes all files with name like "*.war" in /home/ubuntu/wars folder.
|
find /home/ubuntu/wars -type f -name "*.war" -exec rm {} \\;
|
Immediately kill all processes using TCP port 3000 on the system.
|
kill -9 $
|
Print only unique lines in files 'set1' and 'set2'
|
cat set1 set2 | sort -u
|
Search the current directory recursively for files last modified within the past 24 hours ignoring .swp files and paths ./es* and ./en*
|
find . -mtime 0 | grep -v '^\./en' | grep -v '^\./es' | grep -v .swp
|
Update the archive '2009.tar' with the files from the data/ directory tree that match pattern 'filepattern-*2009*'
|
find data/ -name filepattern-*2009* -exec tar uf 2009.tar {} ;
|
Read a line from standard input into variable "message" with escaped prompt "Please Enter a Message: \n\b"
|
read -p "$" message
|
List all directories under current directory
|
find . -type d -exec ls -dlrt {} \;
|
List all leaf directories of the current directory tree
|
find . -type d -links 2
|
display all text files in the folder /user/directory which have been modified in today
|
find /user/directory/* -name "*txt" -mtime 0 -type f
|
Recursively change the user and group of all files in "/var/log/jenkins" to "root"
|
chown -R root:root /var/log/jenkins
|
Find recursively all files matching pattern 'file??' in the xargstest/ directory and print a sorted list of them
|
find xargstest/ -name 'file??' | sort
|
Find all files in the current directory recursively that were last modified more than 5 days ago
|
find ./* -mtime +5
|
Delete all files under '/home/backups' directory tree with '.tgz' or '.gz' extension that were modified more thant 60 days ago
|
find /home/backups -type f -iregex '.*\.t?gz$' -mtime +60 -exec rm {} \;
|
Show a listing of files not modified in over 20 days or not accessed in over 40 days
|
find /mydir \ -exec ls -l {} \;
|
change user and group of the file /usr/bin/aws to user amzadm and group root
|
chown amzadm.root /usr/bin/aws
|
Update timestamps of all files and directories under current directory.
|
find . -print0 | xargs -0 touch
|
Find all directories under /home/username/tmp and set their permission to 770
|
find /home/username/tmp -type d -exec chmod 770 {} +
|
Find all README's in /usr/share
|
find /usr/share -name README
|
Find grub.conf files in entire file system discarding errors in csh or tcsh shell
|
find / -name grub.conf >& /dev/null
|
Find files belonging to the given owner
|
find /path/to/search -user owner
|
Format bash array "${arr}" in columns
|
echo " ${arr[@]/%/$'\n'}" | column
|
Search for 'specific string' in all files matching the name pattern '“*.[txt|TXT]”' under current directory tree
|
find . -name “*.[txt|TXT]” -print | xargs grep “specific string”
|
Create intermediate directories as required and directory project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}
|
mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}
|
Find all PHP files under current directory that contain only one non-blank line
|
find . -type f -name '*.php' -exec grep -Hcm2 '[^[:space:]]' {} + | sed -n '/:1$/{s///;p}'
|
Calculate the md5 sum of all the file metadata in the current directory tree excluding ".svn"
|
find . -name '.svn' -prune -o -type f -printf '%m%c%p' | md5sum
|
Counts lines in file file1 and shows progress bar while doing.
|
tail -n 100 file1 | bar | wc -l
|
Find all regular files in .git and replace every occurrences of 'subdomainB.example.com' with 'subdomainA.example.com' in those files
|
find .git -type f -print0 | xargs -0 sed -i 's/subdomainB\.example\.com/subdomainA.example.com/g'
|
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'
|
display all the hidden files in the directory "/dir/to/search/"
|
find /dir/to/search/ -name ".*" -print
|
Find all 'test' directories in the current directory tree and remove them
|
find . -type d -name 'test' -exec rm -rf {} \;
|
Print "RDBMS exit code : $RC " to the console and append to "${LOG_FILE}"
|
echo " RDBMS exit code : $RC " | tee -a ${LOG_FILE}
|
Display differences between /tmp/test1 and /tmp/test2.
|
diff /tmp/test1 /tmp/test2
|
display all the files in the current folder and traverse from the sub directories
|
find . -type d -depth
|
Searches for 'something' in a large file and prints the matching line
|
grep -n 'something' HUGEFILE | head -n 1
|
Find all files named "filename" in the current directory tree, not descending into "FOLDER1" directories
|
find . -name FOLDER1 -prune -o -name filename
|
Print unique lines in sorted file "A" when compared to sorted files "B", "C", and "D"
|
comm -2 -3 A B | comm -2 -3 - C | comm -2 -3 - D
|
Find files that were modified second last week and archive them
|
find . -type f -mtime +7 -mtime -14 | xargs tar -cvf `date ‘+%d%m%Y’_archive.tar`
|
Find all files that were last accessed less than7 days ago under /home
|
find /home -mtime -7
|
Count the number of the regular files residing under and below ./randfiles/
|
find ./randfiles/ -type f | wc -l
|
Find all files/directories starting with 'readme' (case insensitive) under '/usr/share/doc' directory tree
|
find /usr/share/doc -name '[Rr][Ee][Aa][Dd][Mm][Ee]*'
|
Find all directories under ${1:-.} directory without descending into any sub-directories
|
find ${1:-.} -mindepth 1 -maxdepth 1 -type d
|
Find the files in the current directory that match pattern '*.ISOLATE.*.txt' and move them to folder ./ISOLATE
|
find . -name '*.ISOLATE.*.txt' -maxdepth 1 -print0 | xargs -0 -IFILE mv FILE ./ISOLATE
|
Run 'make -e' with an environment variable 'HOSTNAME' set to the system hostname
|
HOSTNAME=$(hostname) make -e
|
Prints total number of lines of all *.m and *.h files in a current folder and subfolders.
|
find ./ -type f -name "*.[mh]" -exec wc -l {} \; | sed -e 's/[ ]*//g' | cut -d"." -f1 | paste -sd+ - | bc
|
Store content of uncompressed file "$file.fastq" in variable "reads"
|
reads=$(zcat $file.fastq)
|
Display differences between directories repos1 and repos2, ignoring changes due to tab expansion, white spaces and treating absent files as empty.
|
diff -ENwbur repos1/ repos2/
|
Delete empty files and print their names
|
find . -empty -delete -print
|
Create a symbolic link named "$1/link" to the current working directory
|
ln -s "`pwd`" $1/link
|
Exits the entire bash script with defined status code N.
|
exit N
|
Search for all the files in man pages and return the manual page for grep
|
find /usr/share/man/ -regex .*/grep*
|
display all the files in the file system which have been modified in the last 10 minutes
|
find / -mmin -10
|
Find and print all PDF files in the current directory and its sub-directories except for any found in the ./pdfs directory.
|
find . -name "*.pdf" -print | grep -v "^\./pdfs/"
|
Find files ending in "*macs"
|
find -name '*macs'
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.