nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Recursively prints all folders in a current folder that contain files like "*.class". | find . -name "*.class" -print0 | xargs -0 -n1 dirname | sort --unique |
Find all .mp3 files with more than 10MB and delete them | find / -type f -name *.mp3 -size +10M -exec rm {} \; |
Find all files under current directory that are read less than 1 minute ago | find . -amin -1 |
Change the permission of all regular files under current directory tree to 644 | find . -type f -exec chmod 644 {} \; |
Create intermediate directories "tmp" as required and directories real_dir1 and real_dir2 | mkdir -p tmp/real_dir1 tmp/real_dir2 |
set variable r to currently running kernel release, ie. 4.4.0-81-generic | r="$(uname -r)" |
find all the text files in the current directory which have been modified in the last 4 days and not today and copy them to another folder | find . -name "*.txt" -type f -daystart -mtime -4 -mtime +0|xargs -i cp {} /home/ozuma/tmp |
search for files in the current folder using name patterns | find . -name '[mM][yY][fF][iI][lL][eE]*' |
List all files/directories under current directory with their inode numbers, disk space, permission, number of hard links, user name, group name, size, status change time in Y-m-d format and name filed, then write the outptut to /tmp/files.txt | find . -type f -fprintf /tmp/files.txt "%i,%b,%M,%n,%u,%g,%s,%CY-%Cm-%Cd %CT,%p\n" |
find all regular files under the /etc/sysconfig directory that were accessed in the last 30 minutes | find /etc/sysconfig -amin -30 -type f |
List all files in entire file system that are not newer than the ttt file and do not belong to the user wnj | find / \! \ -print |
Fetch 'stackoverflow.com' domain IP addresses from dig DNS lookup | dig stackoverflow.com | grep -e "^[^;]" | tr -s " \t" " " | cut -d" " -f5 |
Copy all files and directories in "/home/" to "/newhome" preserving directory hierarchy and modification time | find /home/ -maxdepth 1 -print | sudo cpio -pamVd /newhome |
From a script, output the name of the script itself, without containing directories. | basename $0 |
Counts lines in each *.php file. | find . -name '*.php' -type f | xargs wc -l |
find regular files under the current directory, whose name ends in .mbox, piping the output to the GNU Parallel command that will rename each file to not have a file extension. | find . -type f -wholename \*.mbox -print0 | parallel -0 mv {} {.} |
Gets domain name from dig reverse lookup. | dig -x 8.8.8.8 | awk '/PTR[[:space:]]/{print $NF}' |
Recursively removes all files named '.svn' in a current folder, and prints messages on each action. | find . -name .svn -exec rm -v {} \; |
Greps domain $domain IP name from long dig listing. | dig $domain | grep $domain | grep -v ';' | awk '{ print $5 }' |
Output all lines from file1 except those present in file2. | diff --new-line-format="" --unchanged-line-format="" < < |
Search /path/to/your/directory for *.avi and *.flv files | find /path/to/your/directory -regex '.*\.\' |
Merge file1 and file2 by outputting all lines where the first comma-separated field of both files matches, followed by extra fields in file1 and those in file2 | join -t, <(sort file1) <(sort file2) |
search all jpg images in current folder and rename them | find . -type f -name "*.jpg" -print0 | xargs -0 rename "s/Image_200x200_/img/" |
Compresses all files in the directory 'PATH_TO_FOLDER' without recursion and keeps uncompressed files from deletion. | find PATH_TO_FOLDER -maxdepth 1 -type f -exec bzip2 -zk {} \; |
display all regular/normal files in the folder /Users/david/Desktop/ | find /Users/david/Desktop/-type f |
Find all 'test' directories in the current directory tree | find -type d -a -name test |
find all the files in the file system which have been modified in the last 30*24 hours | find / -mtime -30 -print |
split compressed content of the directory /home into pieces per 4000 mb named as "/media/DRIVENAME/BACKUPNAME.tgz.NNN" | tar --one-file-system -czv /home | split -b 4000m - /media/DRIVENAME/BACKUPNAME.tgz |
Create symbolic links in current directory for all files located in "dir" directory and have filename extension "jpg" | find dir -name '*.jpg' -exec ln -s "{}" \; |
Normalize the path to command "rename" resolving any symlinks, and display what type of file it is. | file $(readlink -f $) |
Find the directory with least access time under current directory and assign it to $filename | { read -r -d' ' time && IFS= read -r -d '' filename; } < < |
find all files without 777 permision | find / -type f ! perm 777 |
Write "foo" to the real path of the current command's standard output | echo foo | readlink /proc/self/fd/0 |
recursively change user of the direct /home/test/ and all files into it to user test | sudo chown -R test /home/test |
find all directory list which have empty list in /tmp directory . | find /tmp -type d -empty |
find file named foo.txt under current directory. | find . -name foo.txt |
List all directories in maximum 1 level down the current directory | find . -maxdepth 1 -type d -exec ls -dlrt {} \; |
Print the list of files and directories of the current directory including "." | find . \( -name . -o -prune \) |
List all files with their modification time in entire file system that are newer than the file $newerthan and older than the file $olderthan in regards of modification time and sort them according to file modification time | find / -type f -name "*" -newermt "$newerthan" ! -newermt "$olderthan" -printf "%T+\t%p\n" | sort |
Kills all child process and process itself having id 24901. | kill `pstree -p 24901 | sed 's/(/\n(/g' | grep '(' | sed 's/(\(.*\)).*/\1/' | tr "\n" " "` |
Search the system for files and directories owned by user `admin' | find / -user admin -print |
Creates temporary folder in TMPDIR or in '/tmp/', and stores path to created folder in 'dir' variable. | dir=$ |
Find all files and directories and count them | find ./ | wc -l |
find all files in the a direcotry which have been modified in exactly 1 day back | find /home/bozo/projects -mtime 1 |
Add group write permission to all files and directories in the current directory including hidden files and excluding ".." | chmod g+w $(ls -1a | grep -v '^..$') |
find all the files ending with "clj" in the current folder and search for a pattern | find . -name '*.clj' -exec grep -r resources {} \; |
Search /usr/src for filenames not ending in "*,v" | find /usr/src ! \( -name '*,v' -o -name '.*,v' \) '{}' \; -print |
List all files/directories under current directory | find . -ls |
Find all the files in entire file system which are greater than 50MB and less than 100MB. | find / -size +50M -size -100M |
Remove all .sh files in the current directory tree whose names begin with "t" | find . -name "t*.sh" -exec rm -vf '{}' \; |
Find all regular files under $DIRECTORY_TO_PROCESS matching the case insensitive regex ".*\.$FILES_TO_PROCES" where $FILES_TO_PROCES is a variable and not matching the name pattern '$find_excludes' where $find_excludes is another variable, then print the files with null delimiter instead of newline | find "$DIRECTORY_TO_PROCESS" -type f -iregex ".*\.$FILES_TO_PROCES" ! -name "$find_excludes" -print0 |
From the list of words (one per line) in list1.txt, display the number of occurrences of this word in list2.txt and sort the results from highest to lowest count. | grep -Ff list1.txt list2.txt | sort | uniq -c | sort -n |
Copy all files in "/mail" to "/home/username" preserving the directory hierarchy and modification times | find /mail -type f | cpio -pvdmB /home/username |
Merge lines whose first comma-separated field in file 'in1' also appears as a first comma-separated in file 'in2' - both files must be sorted. | join -t, in1 in2 |
Find and delete all hard links in the /home directory tree to file1 | find /home -xdev -samefile file1 | xargs rm |
Hash hostnames in user's known hosts file. | ssh-keygen -Hf ~/.ssh/known_hosts |
find all of the files that are readable | find / -readable |
Join comma-separated information in 4 files | join -t, < < | join -t, - < | join -t, - < |
Convert *.doc files in the current directory tree to the .txt format | find . -name '*.doc' | while read i; do antiword -i 1 "${i}" >"${i/doc/txt}"; done |
Search the file hierarchy for files larger than 100000 KB without searching any mounted removable media | find / -path /media -prune -o -size +200000 -print |
Find all regular files starting from / that have permissions 777 | find / -type f -perm 0777 |
Append ".txt" to all filenames in the current directory tree | find -type f | xargs -I {} mv {} {}.txt |
Creates temporary directory in '/tmp/' folder and saves path to it in 'my_tmp_dir' variable. | my_tmp_dir=$(mktemp -d --tmpdir=/tmp) |
Eliminates partially duplicate lines by column, keeping the last occurrence | tac temp.txt | sort -k2,2 -r -u |
Count the total number of lines in all "*.gz" files in the current directory tree after decompression | find . -type f -name '*.gz' | xargs zcat | wc -l |
Generate the Spanish alphabet and number each character | echo -e {{a..n},ñ,{o..z}}"\n" | nl |
Find all regular files under current directory tree that contain 'some text' in their names excluding paths that contain dot files/directories | find . -not -path '*/\.*' -type f -name '*some text*' |
Represent the UTC date given in time string "1970.01.01-$string1" as number of seconds since the epoch and save it in 't1' variable | t1=$ |
Create a symbolic link named ".bash_profile" to ".bashrc" | ln -s .bashrc .bash_profile |
Change all "JPG" filename suffixes in current directory to "jpeg". | rename -v 's/\.JPG/\.jpeg/' *.JPG |
Find all *.css files under $DIR and print the lines matching the regex '\.ExampleClass.{/,/}' from those files | find ${DIR} -type f -name "*.css" -exec sed -n '/\.ExampleClass.{/,/}/p' \{\} \+ |
set alias "ps" for command 'screen -d -m okular' | alias -s ps='screen -d -m okular' |
Prepend the reverse history number to the output of the history command with arguments "$@" | history "$@" | tac | nl | tac |
search for text files in the folders /home/hobbes/ /home/calvin/ and discard all the errors | find /home/hobbes/ /home/calvin/ -name “*.txt” 2>/dev/null |
Copy the owner and group of "oldfile" to "newfile" | chown --reference=oldfile newfile |
Recursively prints all folders in a current folder that contain files like "*.class". | find . -name "*.class" -print0 | xargs -0 -n1 dirname | sort --unique |
Read one character from standard input into variable "REPLY" | read -n 1 -r |
list all *.java files under the src directory | find src -name "*.java" |
Find all files/directories named 'Desktop' under current directory | find ./ -name Desktop |
Find all regular files starting from level 3 of directory tree ~/container and move them one level up | find ~/container -mindepth 3 -type f | xargs -i bash -c 'mv "{}" $/..' |
Calculate the values of the interval from 0 to pi/2 with a step of 1, add a line number, and write the output to standard output and "x.txt" | octave -q --eval 'printf '|nl|tee x.txt |
Search the home directory tree for regular files modified yesterday | find ~ -daystart -type f -mtime 1 |
Find *.o files with permissions 664 in the current directory tree | find . -name *.o -perm 664 -print |
Replace all occurrences of "StringA" with "StringB" in the *.php and *.html files residing in the current directory tree | find . \ | xargs grep -l StringA | xargs sed -i -e 's/StringA/StringB/g' |
Find all regular files in the current directory tree that match pattern 'btree*.c' | find . -type f -name 'btree*.c' |
list regular files under the current directory | find . -type f |
Attach to a not detached screen session. . | screen -xr 14313 |
Synchronize "/home/user1/" to "wobgalaxy02:/home/user1/" including hidden files | rsync -av /home/user1/ wobgalaxy02:/home/user1/ |
Find all .jpg files in the current directory and below. | find . -name “*.jpg” |
find all files in current folder and display the total lines in them | find . | xargs wc -l |
search for the word "nameserver" in all the configuration files of the /etc folder | find /etc/ -type f -name "*.conf" -print0 | xargs -I {} -0 grep "nameserver" "{}" |
Find all php files in a directory | find . -type f -name "*.php" |
Find all files under current directory and set their permission to 775 | find -type f | xargs chmod 775 |
find all the files (under root file system /) that were changed within the last 24 hours | find / -ctime -1 |
Remove all directories called "test" from the current directory tree | find . -name test -type d -exec rm -r {} + |
Run 'somecommand' in an environment without the FOO variable. | env -u FOO somecommand |
split content of the file inputfile except lines started with "^t:" into pieces per 200 lines | cat inputfile | grep "^t\:" | split -l 200 |
Show process tree with command-line arguments of a process that has id 20238. | pstree -a -p 20238 |
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 |
Create 998 directories one inside another with sequential names folder1, folder2, ... folder998 and create an additional folder named 'folder9991000' inside the last 'folder998' directory | mkdir -p folder$1000 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.