nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
create symbolic links in directory "/your/dest/dir/" to all files located in "/your/source/dir/" and have filename extension "txt.mrg" | find /your/source/dir/ -iname '*.txt.mrg' -exec ln -s '{}' /your/dest/dir/ \; |
Recursively change owner and group to "$JBOSS_AS_USER" of "$JBOSS_AS_DIR/" | chown -R $JBOSS_AS_USER:$JBOSS_AS_USER $JBOSS_AS_DIR/ |
create directory foo | mkdir foo |
Creates temporary file with name formatted like '.script.XXXXXX' in '/tmp/' folder and saves path to it in 'script1' variable. | script1=`mktemp /tmp/.script.XXXXXX`; |
Delete files in $DIR_TO_CLEAN older than $DAYS_TO_SAVE days | find "$DIR_TO_CLEAN" -mtime +$DAYS_TO_SAVE -exec rm {} \; |
Find recursively the latest modified file in the current directory | find . -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" " |
Find all dir* files/directories under parent | find parent -name dir* |
Print the characters in $b that match with any character in $a without printing any whitespace in-between | echo "$b" | grep --only-matching "[$a]" | xargs | tr --delete ' ' |
List all .svn files/directories under current directory | find . -name .svn -exec ls {} \; |
find the file "filename.txt" in the entire file system | find / -name filename.txt -print |
Print info about all mounted file systems, and grand total statistic about available and used space | df --total |
find all the configuration files in /etc folder along with the last access & modification time | find /etc -name "*.conf" -printf "%f %a, %t\n" |
Find the total size of *.jpg files within the current directory tree | find . -type f -iname '*.jpg' -print0 | xargs -r0 du -a| awk '{sum+=$1} END {print sum}' |
Print file system disk space usage in human readable format of the root filesystem | df -h / |
Change the ownership of "/home/bob" to "root" | sudo chown root /home/bob |
Find all directories under /path/to/Dir and set their permission to 755 | sudo find /path/to/Dir -type d -print0 | xargs -0 sudo chmod 755 |
Find directory "your/dir" if it is empty | find your/dir -prune -empty -type d |
list files in /usr modified after the time which /tmp/stamp$$ modified | find /usr -newer /tmp/stamp$$ |
Replace all newlines with spaces in the contents of "file" | sed -e '{:q;N;s/\n/ /g;t q}' file |
Force create a symbolc link named "softlink_name" to "source_file_or_directory_name" without dereferencing "softlink_name" | ln -sfn source_file_or_directory_name softlink_name |
delete all the log files in the current folder | find ./ -name '*.log' | xargs rm |
Remove all *~ files under current directory with confirmation prompt | find . -name '*~' -ok rm {} \; |
print readline bindings that use key code '\\e\\C-k' | bind -P | grep '\\e\\C-k' |
Print out the names and types of all files in the current directory tree | find . -printf "%y %p\n" |
Find "*201512*" regular files in /home/myhome/data/ARCHIVE/ and move them to /home/myhome/ARCHIVE/TempFolder/ | find /home/myhome/data/ARCHIVE/. -name . -o -type d -prune -o -name '*201512*' -print | xargs -i mv {} /home/myhome/ARCHIVE/TempFolder/. |
Search the directories given as arguments to the Bash script for files whose name is not "ss" | find $@ -not -name ss |
Find all directories under /home/mywebsite/public_html/sites/all/modules and set their permission to 750 | find /home/mywebsite/public_html/sites/all/modules -type d -exec chmod 750 {} + |
Find all leaf directories that include only one occurrence of "modules" | find -regex '.*/modules\' \! -regex '.*/modules/.*/modules\' -type d -links 2 |
Extract 8 bytes as an unsigned integer that is "$o" offset into "$rpm" | set `od -j $o -N 8 -t u1 $rpm` |
Sort lines in "set1" and "set2" to standard output preserving only unique lines | sort -u set1 set2 |
find all text files which have extra extensions in the current folder | find . -name '*.text' -exec $SHELL -c '[ ! -f ${1%.*} ]' $SHELL '{}' ';' -print |
Find recursively all Python files in the current directory tree and count the number of lines in them | find . -name '*.py' | xargs wc -l |
Find all directories at level 3 of directory tree $from_dir | find $from_dir -mindepth 3 -maxdepth 3 -type d |
Look for SGID files and directories | find / -perm /g=s |
find files in /dir/path/look/up directory that names are dir-name-here | find /dir/path/look/up -name "dir-name-here" |
find all text files in current folder and delete them | find . -name ".txt" -exec rm "{}" \; |
change the permissions of all the directories to 775 in the current folder | find . -type d -exec chmod 775 {} \; |
find all the files in the current folder which have been modified after a specific timestamp and save the output to a file | find -newer timestamp-file -type f > list-of-files |
Recursively search for all regular files below directory "dir1" in currentd directory, and output the name of each, without any containing directories. | find ./dir1 -type f -exec basename {} \; |
Find all *.txt and *.json files in current directory | find . -type f \( -name "*.txt" -o -name "*.json" \) |
Find all $2 files in $1 path and search for the regex expanded by $3 in those files | find $1 -name "$2" -exec grep -Hn "$3" {} \; |
Searche JSP's for "TODO" lines and append them all to a file with a header showing what file they came from | for f in `find -name \*.jsp` ; do echo "==> $f" >> out.txt ; grep "TODO" $f >> out.txt ; done |
Calculate the md5 sum of every ".py" file in directory tree "/path" | find /path -type f -name "*.py" -exec md5sum "{}" +; |
find all the directories in the current directory which dont have the execute permission. | find -type d ! -perm -111 |
Report total disk usage info on root file system, printing all sizes as power of 1000 | df -H --total / |
Recursively change the owner and group of all files in the current directory to "apache" | find . -maxdepth 1 -not -name "." -print0 | xargs --null chown -R apache:apache |
change the ownership of all the files in the file system from edwarda to earnestc | find / -user edwarda -print | xargs chown earnestc |
Print the PIDs of the current user's instances of "firefox" | ps -u $ | grep firefox | awk '{printf $1}' |
display all the files in the current folder and do not search in sub directories and move them to the directory /directory1/directory2. | find . -maxdepth 1 -type f | xargs -I ‘{}’ sudo mv {} /directory1/directory2 |
Copy the entire directory tree under t1 to t2, do not create a containing t1 directory in t2. | cp -R t1/ t2 |
Find all directories named postgis-2.0.0 under / directory | sudo find / -type d -name "postgis-2.0.0" |
Find all Perl source code files | find . -name "*.pl" |
bind word "pwd\n" to key code "\e[24~" | bind '"\e[24~":"pwd\n"' |
Prints the length and contents of the longest line in filename | cat filename | awk '{print length, $0}'|sort -nr|head -1 |
Print the full path of command "gcc" | which gcc |
Change permissions to 644 of multiple regular files with permissions 755 | find . -type f -perm 755 -exec chmod 644 {} \; |
Print the characters in $b that match with any character in $a without printing any newline | echo "$b" | grep -o "[$a]" | tr -d '\n' |
List files under $CURR_DIR which were modified, accessed or whose status were changed $FTIME ago replacing the $CURR_DIR path string to './' | find ${CURR_DIR} -type f \( -ctime ${FTIME} -o -atime ${FTIME} -o -mtime ${FTIME} \) -printf "./%P\n" |
Remove all files/directories in the current directory without '.git' and '.gitignore' | find -mindepth 1 -depth -print0 | grep -vEzZ '(\.git|/\.gitignore$)' | xargs -0 rm -rvf |
Find SUID files | find / -perm +4000 |
Search for all files named foo, FOO, or any other combination of uppercase and lowercase characters beneath the current directory. | find . -iname foo -type f |
search for the directory "config" in the current folder and change directory to it | cd `find . -name "config"` |
display all the files in the current folder excluding those that are present in the folder "secret" | find . \( -name 'secret' -a -prune \) -o -print |
Search all files and directories either of the directory /home/oracle and /home/databse which contain the "zip" anywhere in the files or directory name . | find /home/oracle /home/database -name '*zip*' |
Merge each line of standard input into a single comma separated line | paste -s -d"," |
Find all first occurrences of directories named '.texturedata' under '/path/to/look/in' directory tree | find /path/to/look/in/ -type d -name '.texturedata' -prune |
The cpio command is a copy command designed to copy files into and out of a cpio or tar archive, automatically preserving permissions, times, and ownership of files and subdirectories. | find . | cpio -pdumv /path/to/destination/dirrectory |
Find all symbolic links containing 'javaplugin' in their names under '/usr' directory tree | find /usr/ -lname *javaplugin* |
display long listing of top ten biggest regular/normal files in the folder /usr/share/man | find /usr/share/man/ -type f -exec ls -S {} + 2>/dev/null | head |
find all the files ending with undo in the current folder and calculate the total size of these files | find . -name "*.undo" -ls | perl -lane '$t += $F[6]; END{print $t}' |
Print a ping request and the number of packets sent, received, and the percentage lost for each ping request to "google.com" | ping google.com | awk '{ sent=NR-1; received+=/^.*.*$/; loss=0; } { if loss=100-(*100) } { print $0; printf "sent:%d received:%d loss:%d%%\n", sent, received, loss; }' |
Run ipython nbconvert with all the file/directory paths under current directory as arguments | find | xargs ipython nbconvert |
Print right aligned numbers from 11 to 24 | yes '' | nl -ba | sed -n -e 11,24p -e 24q |
Find files whose pathnames contain "string" and print these pathnames replacing 'search string' with 'new string' | find . |xargs grep search string | sed 's/search string/new string/g' |
Search the current directory tree for the files with extension "trc" and remove them if they are more than three days old | find . -name "*.trc" -ctime +3 -exec rm -f {} \; |
Force create a symbolic link to "$f" in "~/my-existing-links/" with name the basename of "$f" | ln -sf "$f" "~/my-existing-links/$" |
finda ll the files in the current folder that are modified today. | find ~ -type f -mtime 0 -ls |
find all the files in the entire file system which have been modified in the last 48 hours | find / -mtime -2 -print |
Views text content of compressed FileB file in TarFile archive. | tar -xOf TarFile FileB.gz | zless |
Calculate the md5 checksum of the current directory structure and save it in variable SUM | SUM=$(tree | md5sum) |
Find empty regular files in /dir and its subdirectories | find /dir -type f -size 0 -print |
find all CSS files under currenty directory and use sed to edit them | find . -name "*.css" -exec sed -i -r 's/#\b/#0F0/' {} \; |
Prints total count all non-empty lines in files of a current folder. | rgrep . | wc -l |
Find a directory named 'project.images' in the entire filesystem and show it in long listing format | find / -type d -name "project.images" -ls |
Output all lines from file1 except those present in file2, assuming both files are sorted. | diff file2 file1 | grep '^>' | sed 's/^>\ //' |
find all the files that have been modified in the last 7 days, | find . -mtime -7 -print |
Print the number of 'processors' (both physical and virtual/hypethereading cores) less 1. | cat /proc/cpuinfo | awk '/^processor/{print $3}' | tail -1 |
Find all the files in entire file system which are accessed 50 days back | find / -atime 50 |
Find all .rpm files and change their permissions to 755 | find / -name *.rpm -exec chmod 755 '{}' \; |
Set permission of all files in "img", "js", and "html" to 644 | chmod 644 img/* js/* html/* |
Display a long listing of all regular files with 0777 permission under current directory tree | find . -perm 0777 -type f -exec ls -l {} \; |
find regular files under the current directory, whose name ends in .mbox and using awk run multiple system commands to rename each matched file, to the same name without .mbox at the end | find . -wholename \*.mbox | awk '{new=$0; gsub("\.mbox$", "", new) ; system("mv \"" $0 "\" \"" new "\"") }' |
Find all files whose names end with "~" in the /home/peter directory tree, following symlinks, and delete them | find -L /home/peter -name *~ |xargs rm |
find all the mp3 files in the current folder and move them to another folder | find . -name "*.mp3" -exec mv {} "/Users/sir/Music//iTunes/iTunes Media/Automatically Add to iTunes.localized/" \; |
find all the text files in the current folder | find . -name "*.txt" -print |
Archive "path/to/working/copy" to "path/to/export" excluding files or directories named ".svn" | rsync -a --exclude .svn path/to/working/copy path/to/export |
Compare each .xml file under the current directory with a file of the same name in "/destination/dir/2" | find . -name *.xml -exec diff {} /destination/dir/2/{} \; |
search for the pattern in all the regular/normal files in the entire file system | find / -type f -print0 | xargs -0 grep -i pattern |
Counts lines in file fileName ignoring empty lines and lines with spaces only. | awk '!/^[[:space:]]*$/{++x} END{print x}' filename |
Remove the last two components (directories) of $path | echo $path | rev | cut -d'/' -f4- | rev |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.