nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Prepend the reverse history number as negative values to the output of the history command with arguments "$@" | history "$@" | tac | nl | tac | sed 's/^\( *\)\([0-9]\)/\1-\2/' |
Compress all files in the "$FILE" directory tree that were last modified 30 days ago | find $FILE -type f -mtime 30 -exec gzip {} \; |
List all *.ogg files under your home directory along with their size | find $HOME -name '*.ogg' -type f -exec du -h '{}' \; |
Search for all zero-byte files and move them to the /tmp/zerobyte folder | find test -type f -size 0 -exec mv {} /tmp/zerobyte \; |
Create a copy of index.html in all directories in current directory, pausing for confirmation before overwriting any existing files - names may not contain spaces - names may not contain spaces. | find . -mindepth 1 -maxdepth 1 -type d| xargs -n 1 cp -i index.html |
Find all *.p[lm] files under /users/tom directory that matches both the regex '->get(' and '#hyphenate' in their contents | find /users/tom -name '*.p[lm]' -exec grep -l -- '->get(' {} + | xargs grep -l '#hyphenate' |
Find Flash videos stored by browsers on a Mac | find /private/ 2>/dev/null | grep /Flash |
search for the file "abc" in the current folder or display all the directories | find . -name abc -or -type d |
Find all directories under current directory tree that were modified $FTIME days ago | find . -type d -mtime $FTIME |
Create a symbolic link in target directory "$tmpdir" for each file under the current directory | find $PWD -type f -exec ln -st $tmpdir {} + |
Display file type description of 'file-name' based on contents. | file file-name |
Copy the current directory tree to "newdirpathname" preserving directory hierarchy | find ./ -depth -print | cpio -pvd newdirpathname |
force delete all the files in the current folder expect xml files | find . | grep -v xml | xargs rm -rf {} |
SSH into host "$1" using key file "/path/to/ssh/secret/key" and execute command "$2" | ssh -i /path/to/ssh/secret/key $1 $2 |
Find all regular files under '/usr/bin' directory tree that are less than 50 bytes in size | find /usr/bin -type f -size -50c |
discard all the errors and search for the file "program.c" in the entire file system | find / -name 'program.c' 2>/dev/null |
Search the ./in_save directory for regular files and view the result using pager `more' | find ./in_save/ -type f -maxdepth 1| more |
Print the last space separated word from "Your string here" | echo "Your string here"| tr ' ' '\n' | tail -n1 |
Write "error" to both the log file "log" and standard error | echo "error" | tee -a log 1>&2 |
Count the number of equal lines in sorted files "ignore.txt" and "input.txt" | comm -12 ignore.txt input.txt | wc -l |
Find all broken symlinks under current directory | find -type l -xtype l |
remove all the regular/normal files in the temp folder and do not delete in the sub folders | find /tmp -maxdepth 1 -type f -delete |
Rename all *.jpg files under current directory by appending parent directory name at the beginning of their names | find . -name '*.jpg' -exec bash -c 'd="${1%/*}"; mv "$1" "$d/$d-${1##*/}"' - '{}' \; |
Prints total count of lines of all files in a current folder and subfolders. | find . -type f -exec wc -l {} \; | awk '{ SUM += $0} END { print SUM }' |
split file t.txt into pieces per 30000000 lines named as "t.NN" with numeric suffix | split --lines=30000000 --numeric-suffixes --suffix-length=2 t.txt t |
List the largest file prefixed by its size in bytes of all files under the current directory | find . -type f -name '*.gz' -printf '%s %p\n'|sort -nr|head -n 1 |
Search for '/usr/bin/perl' in all regular files under current dirctory tree and also show a long listing of them | find . -type f -exec grep "/usr/bin/perl" {} \; -ls |
find all the directories with the name "c" in the current folder which are at least 3 levels deep and which are not present in the path "/p/". | find -mindepth 3 -type d ! -path '*/p/*' -name c -print |
Recursively removes $TMPDIR folder, prompting user on each deletion. | rm -r $TMPDIR |
Set 644 permission to all regular files under current directory | chmod 644 `find . -type f` |
search for a word in all the files in the current directory and display the list of matched files. | find . -type f -exec grep -l 'needle' {} \; |
find directory which case-insensitive name is foo in current directory. | find . -iname foo -type d |
search for a word in all c files in the current folder | find . -name '*.c' | xargs grep 'stdlib.h' |
Remount "/home/evgeny" with the "suid" flag set | sudo mount -i -o remount,suid /home/evgeny |
Get files that last had their meta information changed more than 3 days ago | find / -ctime +3 |
Copy recursively "/source/backup" to "/destination" preserving symbolic links, modification times, and permissions | rsync -rtvpl /source/backup /destination |
change the permission of all the normal/regular files from 777 to 755 in the folder "/home/user/demo" | find /home/user/demo -type f -perm 777 -print -exec chmod 755 {} \; |
Show a listing of files not modified in over 20 days or not accessed in over 40 days | find /mydir \(-mtime +20 -o -atime +40\) -exec ls -l {} \; |
Find writable regular files in the current directory | find . -maxdepth 1 -type f -writable |
Truncate all non-empty regular files under the current directory | find . -type f -maxdepth 1 -not -empty -print0 | xargs -0i sh -c "cat /dev/null > \"{}\"" |
Make directories and parents as needed to "${raw_folder}" and "${split_folder}" | mkdir -p ${raw_folder} ${split_folder} |
Count number of lines in all files matching "*R1*.fastq.gz" | zcat *R1*.fastq.gz | wc -l |
Provide a list of all the files edited today to pr, and pipe pr's output to the printer | pr -n 'find . -type f -mtime -1 -print'|lpr |
find all the files in the current folder which are readable | find . -readable |
Recursively copy everything in /source/path whose name doesn't begin with a period, to /destination/path, without overwriting existing files, and outputting a line for each file copied or skipped. | cp -Rvn /source/path/* /destination/path/ |
search for a word in all the java files in the current directory | find . -name "*.java" | xargs grep "Stock" find . -name "*.java" | xargs grep "Stock" find . -name "*.java" | xargs grep "Stock" find . -name "*.java" | xargs grep "Stock" find . -name "*.java" | xargs grep "Stock" find . -name "*.java" | xargs grep "Stock |
Read a single character from standard input with prompt "Are you sure? (y/n) " | read -p "Are you sure? (y/n) " -n 1 |
Change to parent directory and resolve any symlinks in the resulting path, making the physical path the current one. | cd -P .. |
Split "input.txt" into files with 1 line each and use a prefix "output." and a suffix length of 5 | split --lines=1 --suffix-length=5 input.txt output. |
Update the timestamp of '/tmp/$$' to the current month and day | touch -t `date +%m%d0000` /tmp/$$ |
Traverse the filesystem just once, listing setuid files and directories into /root/suid.txt and large files into /root/big.txt. | find / \ , \ \ |
List all leaf directories under current directory | find . -type d -links 2 |
Set the timestamp of B to the same one as A | touch -r A B |
List all files in /home/bozo/projects directory tree that were modified within the last day | find /home/bozo/projects -mtime -1 |
Make a copy of the entire contents of SRCFOLDER called "DESTFOLDER", if DESTFOLDER exists, the copy will be placed within it. | cp -R SRCFOLDER DESTFOLDER/ |
Find all files/directories under current directory tree excluding files/directories with name 'query_to_avoid' | find \! -name "query_to_avoid" |
display a long listing of all the files in the current directory | find . -name * -exec ls -a {} \; |
Download "Louis Theroux's LA Stories" using rsync over ssh | rsync -ave ssh '"Louis Theroux"''"'"'"'"''"s LA Stories"' |
Copy all files below the current directory whose names contain "FooBar" to directory foo/bar/ in user's home directory. | find . | grep FooBar | xargs -I{} cp {} ~/foo/bar |
SSH into "localhost" with forced pseudo-terminal allocation, execute "$heredoc", and save the output to variable "REL_DIR" | REL_DIR="$" |
ERROR - this is for DOS | ping -n 1 %ip% | find "TTL" |
Mount "nifs" filesystem "/dev/mapper/myldm" on "/mnt" as read only | mount -t ntfs -o ro /dev/mapper/myldm /mnt |
change owner and group of the directory $dstdir" to the user and group of the file "$srcdir" | chown $ "$dstdir" |
display the long listing detials of all the files in the folder junk which is in home folder. | find ~/junk -name "*" -exec ls -l {} \; |
find all files in the current folder which have been modified after a specific time stamp and do not search in the subfolders; | find -maxdepth 1 -type f newermt "$timestamp"' |
Exclude directory from find . command | find . -path ./misc -prune -o -name '*.txt' -print |
Copies all files like "*foo*" under the current directory to the '/your/dest' directory. | find . -name "*foo*" | sed -e "s/'/\\\'/g" -e 's/"/\\"/g' -e 's/ /\\ /g' | xargs cp /your/dest |
Find all the files in entire file system which are greater than 50MB and less than 100MB. | find / -size +50M -size -100M |
find all the files in the current folder which which have been modified yesterday and day before yesterday and whose name is of length 1 | find . -name \? -daystart -mtime +0 -mtime -3 |
Delete all lines matching "pattern to match" in "./infile" and make a backup with suffix ".bak" | sed -i.bak '/pattern to match/d' ./infile |
Find files matching regular expression regexp | find . | xargs grep regexp |
Save 'foo' into variable 'bar' in ksh | echo foo | read bar |
Print numbers from 1 to 10 with 2 values per line | seq 10 | awk 'NR%2{printf("%s ", $0); next}1' |
Read a line from standard input into variable "date" with prompt "BGC enter something", and storing typed backslash as backslash symbol | read -p 'BGG enter something:' -r data |
Print the line number of each matching "<phrase>" in "<filename>" | nl -b a "<filename>" | grep "<phrase>" | awk '{ print $1 }' |
find all files in the file system which have not been accessed in the last 2 days | find / -atime +2 |
Find a 400 permission file under /data directory | find /data -type f -perm 400 -print -quit |
Search the current directory tree for files without "test" in their path names | find . -not -regex ".*test.*" |
Save absolute path of "/home/nohsib/dvc/../bop" in variable "absolute_path" | absolute_path=$(readlink -m /home/nohsib/dvc/../bop) |
Find all files/directories named 'pattern' under current directory tree | find . -name "pattern" -print |
display the count of all the directories present in a folder | find /mount/point -type d | wc -l |
Installs 'firefox' package. | yum install firefox |
Write "Hello, world" to standard output and to "/tmp/outfile" | echo "Hello, world" | tee /tmp/outfile |
Print the last 10 lines of "great-big-file.log" | tail great-big-file.log |
find all symbolic links in the current folder | find -type l |
Find all *.gz files/directories under asia and emea directory | find asia emea -name \*.gz -print0 | xargs -0 |
Prefix all files and folders in the current directory with "PRE_" | find * -maxdepth 0 ! -path . -exec mv {} PRE_{} \; |
Delete all __temp__* files/directories under current directory tree | find . -depth -name '__temp__*' -exec rm -rf '{}' \; |
Determine the user associated with stdin | who -m |
Find the largest original ".gz" file in the current directory tree | find . -name '*.gz' | xargs gzip -l | tail -n +2 | head -n -1 | sort -k 2 | tail -n 1 | awk '{print $NF}' |
Remove duplicate lines in "file_name" and print the output on stdout | awk '{print}' file_name | sort -t$'\t' -k2,2 | uniq -u --skip-fields 1 | sort -k1,1 -t$'\t' | cut -f2 -d$'\t' |
List empty directories in the current directory tree | find . -depth -empty -type d |
display a long listing of the files all non emoty files in current folder which have been modified 60 minutes ago | find . -mmin 60 -print0 | xargs -0r ls -l |
Executes 'true'. then makes 'xargs' fail executing 'false' and return 123 exit code. | true | xargs false |
Print a tab separated table in "table.txt" with cell borders | sed -e 's/\t/_|/g' table.txt | column -t -s '_' | awk '1;!{print "-----------------------------------------------------------------------";}' |
Gets MAC address of 'eth0' network interface. | ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' |
Prints line count of each file within current directory. | find . -type f -print | xargs -L1 wc -l |
Stores system load average number in the 'proc_load_average' variable. | proc_load_average=$(w | head -1 | cut -d" " -f13 | cut -d"," -f1-2 | tr ',' '.') |
Remove leading and trailing spaces or tabs from "$string" | echo "$string" | sed -e 's/^[ \t]*//' | sed -e 's/[ \t]*$//' |
find all js files which path neither ./dir1 nor ./dir2 nor ./dir3 | find . -name '*.js' -not \ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.