nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Search the current directory tree for files whose name is ".note", case insensitive | find -type d -exec find {} -maxdepth 1 \! -type d -iname '.note' \; |
Remove newline characters from "file.txt" | paste -sd "" file.txt |
Execute "bash -c your_script" every 2 seconds | watch bash -c your_script |
Merge already sorted files "*.txt" and split the result into files of at most 1000000 lines each with a numeric suffix and a prefix "output" | sort -m *.txt | split -d -l 1000000 - output |
Change permissions to u=rw,g=r,o= for all files inside the current directory tree | find . -type f -exec chmod u=rw,g=r,o= '{}' \; |
search for al cpp files in current folder and display distinct parent directory of these files in sorted order | find . -name "*.cpp" | while read f; do dirname "$f" ; done | sort -u |
search for a word in all the files in the current directory | find . -type f -exec grep 'needle' {} \; |
List all directories and subdirectories | find . -type d |
display all the regular files in the folder "$" which are modified in the last $*24 hours and excluding hidden files | find ${FOLDER} -type f ! -name \".*\" -mtime -${RETENTION} |
search for the word foo in all the js files in the current folder | find . -name "*.js" -exec grep -iH foo {} \; |
find all the files in the current folder which have a set uid set | find . -perm -4000 -print |
Display the contents of variable "a" converted to lowercase. | echo "$a" | awk '{print tolower}' |
Count line numbers on files and record each count along with individual file name. | find /home/my_dir -name '*.txt' | xargs grep -c ^.* |
Force create a hard link named "non_secret_file.txt" to "secret_file.txt" | ln -f secret_file.txt non_secret_file.txt |
Saves exit statuses of piped commands in a system variable PIPESTATUS='([0]="1" [1]="2") | false | true |
Find all the *.txt files in the current directory older than 48 hours | find . -maxdepth 1 -name '*.txt' -mtime +2 |
Read a line from standard input with prompt "Continue (y/n)?" and save response in variable "choice" | read -p "Continue (y/n)?" choice |
Calculate the SHA1 sum for the contents of the regular files in the path/to/folder directory tree | find path/to/folder -type f -print0 | xargs -0 sha1sum | sha1sum |
Create the directory '.npm-packages' in the user's home directory($HOME) | mkdir "${HOME}/.npm-packages" |
Execute the file utility for each file found under /etc or below that contains "test" in its pathname | find /etc -print0 | grep -azZ test | xargs -0 file |
create a symbolic link named "/usr/lib/jvm/default-java" to file "/usr/lib/jvm/java-7-oracle" | sudo ln -s /usr/lib/jvm/java-7-oracle /usr/lib/jvm/default-java |
Find all files on the system whose names are 'drush' | find / -name drush |
Find broken symlinks in current directory | find . -type l -xtype l |
return every file that does not have bar somewhere in its full pathname | find . ! -path '*bar*' -print |
display all the files in the file system which belong to the user with the id 1005 | find / -uid 1005 |
Save the user name of the current user to variable "me" | me="$(whoami)" |
Remove all empty files in /tmp/ and below | find /tmp -type f -empty -print | xargs rm -f |
Find symbolic links in /usr/lib and /usr/lib64 to files whose pathnames contain "libstdc++" | find /usr/lib/ /usr/lib64/ -lname "*libstdc++*" |
display a long listing of all images with the name "articles" in the current folder | find . -iname "Articles.jpg" -exec ls -l {} \; |
Print each character in "orange" on a new line | echo orange | fold -w 1 |
Find files/directories under current directory that matches 'projects/insanewebproject' in their paths | find -ipath 'projects/insanewebproject' |
Display inputfile all on one line | awk '{printf "%s|", $0} END {printf "\n"}' inputfile |
Find all 50MB files | find / -size 50M |
Search for all files in the current directory recursively whose names end with "Linkin Park" | find . -name "*Linkin Park" |
Find files and directories that are at least seven levels of nesting in the directory /usr/src | find /usr/src -name CVS -prune -o -mindepth 7 -print |
Set shell option 'checkwinsize'. | shopt -s checkwinsize |
Change to folder where the oracle binary is. | cd $(dirname `which oracle`) |
Delete all files/directories taken by the glob pattern * except the ones with the name 'b' | find * -maxdepth 0 -name 'b' -prune -o -exec rm -rf {} \; |
Prints brief information about available package with word 'zsh'. | yum list zsh |
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 |
Find and replace xxx with yyy in whole directory tree | find . -type f -exec perl -pi -e 's|xxx|yyy|g' {} ; |
Append ".txt" to all filenames in the current directory tree | find -type f | xargs -I {} mv {} {}.txt |
find all the directory's from root which have the sticky bit on and display their details. Do not display any errors on the standard output. | find / -type d -perm -1000 -exec ls -ld {} \; 2> /dev/null |
find all the files in the entire file system whose size is between 50Mb to 100MB | find / -size +50M -size -100M |
Find all files/directories in directories/files taken from the glob pattern '/tmp/test/*' that were modified within the last day (day counted from today) | find /tmp/test/* -daystart -mtime -1 |
Execute "xbacklight -set 0% && sleep 20 && xbacklight -set 100%" every 1200 seconds | watch -n1200 "xbacklight -set 0% && sleep 20 && xbacklight -set 100%" |
change the permission of all the regular/normal files in the current folder from 777 to 755 | find . -type f -perm 777 -exec chmod 755 {} \; |
list any files modified since /bin/sh was last modified | find . -newer /bin/sh |
find all the regular/normal files ending with ".mod" in a folder and pass them as input to remodup command | find $DIR -name "*.mod" -type f -exec bash -c 'remodup "$1"' - {} \; |
Find all .gif files in the /var/www directory tree that are between 5 kB and 10 kB in size | find /var/www -name *.gif -size +5k -size -10k |
Display the count of regular files for which the owner has read and execute permission under 'home/magie/d2' directory tree | find home/magie/d2 -type f -perm -u+rx | wc -l |
make directory "/etc/cron.15sec" | mkdir /etc/cron.15sec |
create directory dir | mkdir -p dir |
find all the files in the current folder that have been modified in the last 7 days | find -mtime -7 -daystart |
Find files/directories that is under group 'root' or have no group and set their group to 'apache' | find /var/www -group root -o -nogroup -print0 | xargs -0 chown :apache |
Mount "device_name" on "mount_point" | sudo mount device_name mount_point |
Search for files that are at least 1.1GB | find / -size +1.1G |
Prints current directory name | pwd | grep -o "\w*-*$" |
run command "/path/to/my_daemon & echo \$! > /tmp/su.joe.$$" as user joe | su - joe -c "/path/to/my_daemon & echo \$! > /tmp/su.joe.$$" |
Find all or single file called FindCommandExamples.txt under / directory of owner root | find / -user root -name FindCommandExamples.txt |
run command "command" as user user1 with password "password" | echo password | su user1 -c 'command' |
Find all *company* files/directories under /root/of/where/files/are directory | find /root/of/where/files/are -name *company* |
display all the php files in the current folder which do not have the permission 644 | find . -type f -name "*.php" ! -perm 644 |
Find <fileName> files/directories under current directory | find -name "<fileName>" |
Find directories in /proc and show only those that doesn't match the regex '/proc/[0-9]*($|/)' | find /proc -type d | egrep -v '/proc/[0-9]*($|/)' | less |
Recursively copies all files in the current directory but ones that names match pattern "dirToExclude|targetDir" to the 'targetDir' directory, printing info message on each operation. | cp -rv `ls -A | grep -vE "dirToExclude|targetDir"` targetDir |
Print the day 1 day ago | date --date='1 days ago' '+%a' |
Find x* files/directories under /tmp directory whose status was changed less than 1 day ago and move them to ~/play | find /tmp/ -ctime -1 -name "x*" -exec mv '{}' ~/play/ |
Find all regular files that reside in the current directory tree and were last modified more than 5 days ago | find . -type f -mtime +5 |
delete recursively, without prompting, any files or directories under the current directory that case insensitively match the filename ".svn" | find . -iname .svn -exec rm -rf {} \; |
find all regex '\./[a-f0-9\-]\{36\}\.jpg' files | find . -regex '\./[a-f0-9\-]\{36\}\.jpg' |
Display the output of "ls" for an 80 character wide display | ls | column -c 80 |
Compress all files under current directory tree with gzip | find . -type f -print0 | xargs -0r gzip |
Find all the files under /home directory with name tecmint.txt | find /home -name tecmint.txt |
Delete all regular files with '.txt' extension that were modified in more than 25 minutes ago in maximum 1 level down the directory '/home/u20806/public_html' | find /home/u20806/public_html -maxdepth 1 -mmin +25 -type f -name "*.txt" -delete |
find files which full path name is foo/bar under foo directory and print | find foo -path /tmp/foo/bar -print |
Find a hostname that resolves to IP '173.194.33.71' | dig +short -x 173.194.33.71 |
Recursively add read and directory access to all permissions of all files and directories | chmod -R a+rX * |
display all the C, CPP, Header files in the kat folder | find kat -type f \ |
change the permission of all the normal/regular files to 644 in the current folder | find -type f -exec chmod 644 {} \; |
Get the total size of all files under dir1 directory | find dir1 ! -type d -printf "%s\n" | awk '{sum += $1} END{printf "%f\n", sum}' |
display all regular/normal files in temp folder and display the filename along with file size | find tmp -type f -printf "f %s %p\n" |
Output all lines in 'file' comparing the first 12 characters and discarding any adjascent lines where these characters are duplicates. | uniq -w12 -c file |
Search the current directory tree for files modified less than 5 days ago | find . -mtime -5 |
display all the regular/normal files in the folder /path/ which have not been modified today ( from day start ie, 00:00 ) | find /path/ -type f -daystart -mtime +0 |
Find files in the current directory excluding CVS, SVN, GIT repository files and all binary files. | find . -not \( -name .svn -prune -o -name .git -prune -o -name CVS -prune \) -type f -print0 | xargs -0 file -n | grep -v binary | cut -d ":" -f1 |
Search the current directory tree for files AAA and BBB | find . \( -name AAA -o -name BBB \) -print |
Returns exit status 0 and prints exit status of previous command. | false | echo "${PIPESTATUS[0]}" |
find directory names starts with 'bar' | find . -path './bar*' -print |
Count files in the current path by modification month | find . -maxdepth 1 -type f -printf '%TY-%Tm\n' | sort | uniq -c |
find all the files in the folder "myfiles" which have been modified exactly 48 hours back. | find /myfiles -mtime 2 |
Find all files with '.txt' (case insensitive) extension under $dir directory non-recursively and sort them numerically | find "$dir" -maxdepth 1 -type f -iname '*.txt' | sort -n |
find all the ".flac" files in the current folder and convert them to mp3 with 160k bit rate | find . -name "*.flac" -exec ffmpeg -i {} -ab 160k -map_metadata 0 -id3v2_version 3 {}.mp3 \; |
Write the current date and time followed by " 1" to the console and append to "log.csv" | echo $(date) "1" | tee -a log.csv |
Display differences between /destination/dir/1 and /destination/dir/2 excluding XML files. | diff /destination/dir/1 /destination/dir/2 -r -x *.xml |
Find files with 002 permission under /tmp and print them with the string 'Found world write permissions:' printed as the first line of output | find /tmp -type f -perm -002 | sed '1s/^/Found world write permissions:\n/' |
search in current directory downwards all files whose size is less then 10 bytes | find . -size -10c -print |
Gets a job with defined number back to the foreground. | fg 1 |
Print common files of directory "1" and "2" | comm -12 < < |
Uncomment every entry in current user's cron job list which contains "test.sh" | crontab -l | sed '/# *\\{5\}[^ ]*test\.sh/s/^# *//' | crontab - |
Subsets and Splits