nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Take first text field from file 'file.txt' as a domain name and get short A record for this one.
cut -d' ' -f1 file.txt | xargs dig +short
kill all active jobs
jobs -p | xargs kill -9
Change the ownership of all aluno1's files in the current directory and below to aluno2
find . -user aluno1 -exec chown aluno2 {}
Find the process id of mysql
ps -A|grep mysql
Find regular files under '/somefolder' directory tree satisfying the options/conditions/operations provided in ${ARGS[@]} array with find command
find /somefolder -type f ''
Write out the entire directory hierarchy from the current directory
find .
Find and remove all .mp3 regular files under the current directory and below
find . -type f -name "*.mp3" -exec rm -f {} \;
find all the normal/regular files in current folder and search for a pattern
find . -type f -print0 | xargs -0 grep pattern
Copy all files matching "file_name.extension" to "/path/to/receiving/folder" preserving directory hierarchy
find . -name 'file_name.extension' -print | cpio -pavd /path/to/receiving/folder
Gets IP address of 'en0' network interface.
ifconfig en0 | awk '/inet addr/{print substr}'
find a 'fool.scala' named regular file under /opt /usr /var those directories.
find /opt /usr /var -name foo.scala -type f
Find all files/directories that are owned by user 'eric' under current directory tree
find -user eric -print
split file /usr/bin/firefox into pieces per 1000 lines
split -n 1000 /usr/bin/firefox
Change all files with no user under "/var/www" to have owner "root" and group "apache"
sudo find /var/www -nouser -exec chown root:apache {} \;
find files which modification time is 7 days ago
find . -mtime -7
Find all files that belong to group developer
find /home -group developer
dispaly all the empty regular/normal files in the current folder
find . -type f -empty
Find the directory with least modification time under current directory
find -type d -printf '%T+ %p\n' | sort | head -1
Find files in the current directory excluding CVS, SVN, GIT repository files and all binary files.
find . -not \ -type f -print0 | xargs -0 file -n | grep -v binary | cut -d ":" -f1
Change the ownership of "/etc/udev/rules.d/51-android.rules" to "root"
sudo chown root. /etc/udev/rules.d/51-android.rules
For each item in array "alpha", display the basename, that is the part following the last slash, or the whole item if no slash is present.
basename -a "${alpha[@]}"
Delete the files under the current working directory with inode numbers specified on standard input
xargs -n 1 -I '{}' find "$(pwd)" -type f -inum '{}' -delete
Creates temporary folder in TMPDIR (if defined) or in '/tmp/', and stores path to created folder in 'dir' variable.
dir=$(mktemp -d)
Find all files in current directory that were modified less than 1 day ago, and create cpio archive in $backup_dir
find . -mtime -1 | cpio -oa 2>/dev/null |
Find files matching pattern $2 in the $1 directory recursively and search them for text $3, where $1, $2, $3 are the command line arguments to the Bash script
find $1 -name "$2" | grep -v '/proc' | xargs grep -Hn "$3" {} \;
Unzip and untar "myarchive.tar.gz" and check for corruption
gunzip -c myarchive.tar.gz | tar -tvf -
Remove group write permission on all files output by "compaudit"
compaudit | xargs chmod g-w
Locate files with user permissions rwx owned by my_user
find . -user my_user -perm -u+rwx
Display the current directory tree except files or directories starting with "3rd"
tree -I '3rd*'
search for a regular/normal file "myfile" in the entire file system excluding the folder in excluded_path
find / -path excluded_path -prune -o -type f -name myfile -print
Change all occurrences of "foo" to "bar" in the file "file.txt"
echo ',s/foo/bar/g; w' | tr \; '\012' | ed -s file.txt
Save number of strings with $expression pattern in 'foo.txt' to 'big_lines' variable.
big_lines=`cat foo.txt | grep -c "$expression"`
list all zero-length files under the current directory
find . -empty -exec ls {} \;
search for the file "filename" in the entire file system
find / -name filename
list all the ".ksh" files in the current directory
find . -ls -name "*.ksh"
Search the /myfiles directory tree for files that are 5 512 byte blocks in size
find /myfiles -size 5
find all the files in the folder "myfiles" which have not been accessed in the last 30 days
find /myfiles -atime +30
Search the current directory recursively for regular files last accessed less than 2 days ago
find . type -f -atime -2
Creates temporary folder and saves path to it in a 'tempd' variable.
tempd=`mktemp -d`
Send TERM signal to process with id listed in '/var/run/DataBaseSynchronizerClient.pid' file
kill `cat /var/run/DataBaseSynchronizerClient.pid`
Search the system for a file by its content limiting the search to regular files smaller than 10KB
find / -type f -size -10k 2>/dev/null -print0 | xargs -0 egrep '\bsomeknowncontent\b'
change the permissions of all the directories in the current folder
find . -type d | xargs chmod 2775
Print a single line of numbers from "001" to "010"
yes | head -n 10 | awk '{printf( "%03d ", NR )}' ##for 01..10
Search the system for directories named "needle" suppressing error messages
find / -type d -name "needle" 2>/dev/null
search for text files in the current folder which do not have write access to others
find . -type f \
Find all files which are accessed after modifying /etc/passwd files.
find -newer /etc/passwd
Interpret all lines containing an equal sign in myfile (usually, grab all variables from myfile into current shell)
grep "=" myfile | source /dev/stdin
Delete all files named 'sample' (case insensitive) under '/home/user/Series' directory tree with superuser privilege
sudo find /home/user/Series/ -iname sample -exec rm {} \;
Find files in the current directory tree whose status was changed within the last 60 minutes
find . -cmin -60
Search for 'js' in all files under current directory that match 'some string' in their names
find . | grep 'some string' | grep js
Overwrites file $FILE with random content, then truncates and deletes it.
shred -u $FILE
Find all foo.mp4 files in the current directory tree and print the pathnames of their parent directories
find ./ -name "foo.mp4" -printf "%h\n"
find all files in the file system with the permissions 777 and having the word "filename" in their name.
find / -perm 777 -iname "filename"
Recursively prints all files in a current folders, and searches "stringYouWannaFind" in file content ignoring case differences, and preceding found string with its number in file.
find ./ -type f -print -exec grep -n -i "stringYouWannaFind" {} \;
Print the current working directory and the base name of "$1"
echo "$/$"
SSH into host "server" as user "user"
ssh user@server
Recursively removes all files like '*.xyz' in a current folder.
find . -name \*.xyz -exec rm {} \;
find all the directories in the current folder and create the same directory structure in a remote machine using ssh
find -type d | ssh server-B 'xargs -I% mkdir -p "/path/to/dir/%"'
find all files under "/usr"
find /usr -print
Write the output of "someCommand" to standard output and "someFile"
someCommand | tee someFile
Find all directories named essbase under /fss/fin
find /fss/fin -type d -name "essbase" -print
Print lines of 'file' reverted order, and reverted characterwise
tac file | rev
Print the list of all files in the current directory except for SVN, CVS, GIT, and binary files
find . -not \ -type f -print0 | xargs -0 file -n | grep -v binary | cut -d ":" -f1
Merge already sorted files "file*.txt" and split the result into files of at most 100000 lines each with a prefix "sorted_file"
sort --merge file*.txt | split -l 100000 - sorted_file
Find files matching an exact set of permissions
find / -perm 644
Find all directories under ~/code and replace all newlines with : in the output then remove the last :
find ~/code -type d | tr '\n' ':' | sed 's/:$//'
Search the *.cc files in the current directory tree for string "xxx"
find . -name "*.cc" -print -exec grep "xxx" {} \;
display all the configuration files in the etc folder
find /etc -name '*.conf'
Split "$ORIGINAL_FILE" into files of at most "$MAX_LINES_PER_CHUNK" lines each with a prefix "$CHUNK_FILE_PREFIX"
split -l $MAX_LINES_PER_CHUNK $ORIGINAL_FILE $CHUNK_FILE_PREFIX
Print the last command in history
history | tail -1 | awk '{print $1}'
Finds name of a current month and saves it in a 'month' variable.
month=$
Delete and count files in $DIR_TO_CLEAN that are older than $DAYS_TO_SAVE days
find "$DIR_TO_CLEAN" -type -f -mtime "+$DAYS_TO_SAVE" -exec rm {} \; -printf '.' | wc -c
display all normal/regular files in current folder
find . -type f
Find files recursively with extension "ext"
find . -name "*.ext"
Terminates shell before 'echo foo' if 'set -e' was applied and shell behavior matches the POSIX standart.
echo $
Find all files that were last modified less than7 days ago under /home
find /home -mtime -7
Print the largest 20 files under current directory
find . -type f -printf '%k %p\n' |sort -n |tail -n 20
Find the number of regular files under and below directory /path/to/dir
find /path/to/dir -type f -exec printf %.sX {} + | wc -c
Delete all files/directories with inode number 117672808 under current directory tree
find -inum 117672808 -exec rm {} \;
Print "hello" followed by the current user name
echo hello `whoami`
Make 3 directories named "~/Labs/lab4a/folder" followed by a 3 width zero padded number from 0 to 3
mkdir $
Find all CDC* files under current directory that were accessed less than 1 day ago and delete the first and last lines from those files and count the number of lines in the output
find . -type f -name "CDC*" -ctime -1 -exec sed -i'' -e '1d' -e '$d' '{}' \ | wc -l
display all the regular/normal files in current folder
find . -type f -print0
display all the files in the folder "/dev" which belong to the user "peter"
find /dev -user "peter" |more
this find command Substitute space with underscore in the file name replaces space in all the *.mp3 files with _
find . -type f -iname '*.mp3' -exec rename '/ /_/' {} \;
Search for "1234567890" in every gzip file modified between 8:00 and 9:00 on 2014-04-30
find . -newermt '2014-04-30 08:00:00' -not -newermt '2014-04-30 09:00:00' |xargs gunzip -c | grep 1234567890
Find "file.xml" under the current directory and change directory to its parent
cd `find . -name file.xml -printf %h`
find all the regular/normal files in all the directories in the /some/dir and delete them
find /some/dir -type d -exec find {} -type f -delete \;
find all the files in the file system which have sticky bit enabled to the user
find / -perm -u+s
View manual page of the find command
man find
Print a sorted list of the extensions of the regular files from the current directory tree
find . -type f | grep -o -E '\.[^\.]+$' | sort -u
Move all the .c files from the current directory tree to temp/
find . -name "*.c" -print0 | xargs -0 -n1 -I '{}' mv '{}' temp
search for all the directories in a folder and limit the search to current folder and give them as input to the python script
find /stuff -type d -printf '%P\0' | xargs -0 script.py
Print all '-' separated digits in file 'infile' as dot separated digits
grep -Eo '{3}[0-9]+' infile | tr - .
run command "set -a; . /path/to/nullmailer-vars; set +a; /usr/sbin/logcheck" with a bash as user root
su -s /bin/bash -c "set -a; \ . /path/to/nullmailer-vars; \ set +a; \ /usr/sbin/logcheck" logcheck
display all the files in the current folder expect perl shell and python fiels
find . -not -name "*.pl" -not -name "*.sh" -not -name "*.py"
View the man page of find
man find
Run an awk program on every TXT file found in the current directory tree
find . -name "*.txt" -print -exec awk '{if{print;n++}}' {} \;
Compare *.csv files in the current directory tree with their analogs stored in /some/other/path/
find . -name "*.csv" -exec diff {} /some/other/path/{} ";" -print
Create an archive named newArch from the contents of ./test directory
find ./test -printf "././%f\n"| cpio -o -F newArch