nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Print IP addresses of the host name
hostname -I
find files in /tmp directory that named are core and deletes them
find /tmp -name core -type f -print | xargs /bin/rm -f
Replace all non-punctuation characters with newlines from standard input
tr -sc '[:punct:]' '\n'
Counts lines in file $file ignoring '//' commented lines, lines with spaces only and empty lines.
cat $file | sed '/\/\//d' | sed '/^\s*$/d' | wc -l
enable extglob expansion and create symbolic links in "bar2" directory to all files located in "bar1" directory that are not directory and do not have".cc" filename extension
shopt -s extglob; cd bar2; ln -s ../bar1/foo! .
display all instances of "foo.cpp" file in the current folder which are not in the sub directory tree ".svn"
find . -name 'foo.cpp' '!' -path '.svn'
Locates bzip2 command in a system.
which bzip2
Copy directory hierarchy from the current working directory to "/path/to/backup/"
find . -type d -exec mkdir -p -- /path/to/backup/{} \;
Print each line in "file1" whose first word does not exist as the first word of any line in "file2"
join -v 1 < <
find a.out, *.o and core files under the current directory and sub-directories and delete them.
find . \ -exec rm {} \;
Count the number of files in the /usr/ports directory tree whose names begin with 'pkg-plist' and which contain 'unexec.rmdir%D'
find /usr/ports/ -name pkg-plist\* -exec grep 'unexec.rmdir %D' '{}' '+' | wc -l
Recursively copies everything from '/source/path/*' to the '/destination/path/', preserving from overwriting existing files, and printing info message on each operation.
cp -Rvn /source/path/* /destination/path/
Compare *.csv files in the current directory tree with their analogs stored in /some/other/path/ prompting before running `diff'
find . -okdir diff {} /some/other/path/{} ";"
Saves in 'result' variable list of groups which user $line belongs to, and not matching pattern "_unknown|sciences|everyone|netaccounts"
result=$(groups "$line" | sed 's/ /\n/g' | egrep -v "_unknown|sciences|everyone|netaccounts")
display a list of all regular/normal files in the current folder
find . -type f -ls
Find all regular files that contain 'linux' in their names under '/root' directory tree
find /root -type f -iname "*linux*"
display all files in the current folder
find . -iname "*$@*" -or -iname ".*$@*"
Find all *.cls files/directories under current directory and print '{if(length($0) > L) { LINE=$0; L = length($0)}} END {print LINE"L"L}' for each of them where $0 is expanded to the file/directory path
find . -iname "*.cls" -exec echo '{if(length($0) > L) { LINE=$0; L = length($0)}} END {print LINE"L"L}' {} \;
Remove all regular files from the current directory tree whose names do not end with "txt"
find . -type f -not -name '*txt' -print0 | xargs -0 rm --
Find all 50MB files in file system
find / -size 50M
Search the .css files in the /starting/directory tree for ".ExampleClass"
find /starting/directory -type f -name '*.css' | xargs -ti grep '\.ExampleClass' {}
find the depth of all the files in current folder and display the depth and file name
find folder1/ -depth -type f -printf "%d\t%p\n"
Search the current directory for HTML files whose names begin with "a"
find . -maxdepth 1 -name a\*.html
Find all regular files in the current directory tree and count them
find -type f | wc -l
Sort "file" using a buffer with a size 50% of main memory
sort -S 50% file
Find files/directories that belong to user 'ian' under '/tmp' directory tree
find /tmp -user ian
change user and group of the file "/var/run/docker.sock" to user root and group dockerroot
sudo chown root:dockerroot /var/run/docker.sock
Find all files which belong to user lal and change their ownership to ravi
find / -user lal -exec chown ravi {} \;
Split "ADDRESSS_FILE" into files containing at most 20 lines and prefix "temp_file_"
split -l20 ADDRESSS_FILE temp_file_
Force create a hard link named '/home/user/Musik/youtube converted/aesthesys~ I Am Free, That Is Why I'"'"'m Lost..mp3' with target '/home/user/Musik/mix-2012-13/aesthesys~ I Am Free, That Is Why I'"'"'m Lost..mp3'
ln -f '/home/user/Musik/mix-2012-13/aesthesys~ I Am Free, That Is Why I'"'"'m Lost..mp3' '/home/user/Musik/youtube converted/aesthesys~ I Am Free, That Is Why I'"'"'m Lost..mp3'
execute command "who" when key "\eW" is pressed
bind -x '"\eW":"who"'
Remount "/system" with read and write permission
mount -o rw,remount /system
Print the sorted unique column of usernames of users who are currently logged in
finger | cut -d ' ' -f1 | sort -u
split the first 100 lines of the file "datafile" per lines with size 1700 bytes
sed 100q datafile | split -C 1700 -
Find all file in current directory with have .c extenstion & have 777 permission . delete then
find . -name "*.c" -a -perm -777 | xargs rm -rf
search the pattern ^PyErr in all the ".c" files in the folder Lib/
find Lib/ -name '*.c' -print0 | xargs -0 grep ^PyErr
Strip all '\' and newlines from $output and save the result to variable 'output'
output=$(echo "$output" | tr -d '\' | tr -d '\n')
Print lines in file 'filename' that do not match the regex 'pattern'
grep -v 'pattern' filename
find all empty files in the current directory ( empty file = size 0 bytes )
find . -size 0
Print the output of history without line numbers
history | sed 's/^[ ]*[0-9]\+[ ]*//'
Copy a comlex directory tree from one machine o another while preserving copy permissions and ownership
find . -depth -print | cpio -o -O /target/directory
Compress all ".txt" files in all sub directories with gzip
gzip */*.txt
Find all regular files under $DIR directory tree whose paths match the regex ".*\.${TYPES_RE}" where ${TYPES_RE} expands as a variable
find ${DIR} -type f -regex ".*\.${TYPES_RE}"
display the number of lines in all the ".c" files in the current folder
find . -name "*.c" -print0 | xargs -0 wc -l
find all the files in the home folder which have not been modified in the last 1 year.
find $HOME -mtime +365
Fix permissions for a group of files with given extension
find /usr/local -name "*.html" -type f -exec chmod 644 {} \;
Remove directories in /media/1Tb/videos modified more than 7 days ago
find /media/1Tb/videos -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \;
Write "fifo forever" infinitely using the named pipe "fifo" by writing its contents to standard output and to "fifo"
echo "fifo forever" | cat - fifo | tee fifo
Prints the Nth line of output from 'ls -1'
ls -1 | (for () ; do read ; done ; head -n1)
Find all regular files whose names contain "@" in directory tree ~/$folder
find ~/$folder -name "*@*" -type f
Find all readme.txt files/directories under your home directory
find ~ -name readme.txt
Show global windows options.
tmux show-options -g
Delete all files/directories named 'file' under current directory tree
find -name file -delete
File 'save_pid.txt' contains a process ID, instantly kill this process with SIGKILL signal.
kill -9 `cat save_pid.txt`
Removes all files from current folder but 5 newest ones.
rm `ls -t | awk 'NR>5'`
keep only read access to all the files in a directory.
find /path/to/dir ! -perm 0644 -exec chmod 0644 {} \;
Disables shell option 'dotglob'.
shopt -u dotglob
force delete all the core files in the home folder
find $HOME -name core -exec rm -f {} \;
split $SOURCE_FILE" into pieces per 100 lines
split -l 100 "$SOURCE_FILE"
Run checksums recursively from the current directory, and give back the filenames of all identical checksum results
find ./ -type f -print0 | xargs -0 -n1 md5sum | sort -k 1,32 | uniq -w 32 -d --all-repeated=separate | sed -e 's/^[0-9a-f]*\ *//;'
Find all *.pdf files under ./polkadots
find ./polkadots -type f -name "*.pdf"
find all normal/regular files in current folder and display the total lines in them
find . -type f -exec wc -l {} +
Find all *fink* files/directories under current directory
find . -name "*fink*" -print
Recursively finds all bzip2 compressed files in a current folder and decompresses them.
find ./ -iname "*.bz2" -exec bzip2 -d {} \;
List all leaf directories (directories which don't contain any sub-directory) under current directory
find . -type d -links 2
find all files in the current directory do not display the files which are not readable
find . ! -readable -prune
Connect to host 'hostname' as user 'username' by forcing host key confirmation
ssh -o UserKnownHostsFile=/dev/null username@hostname
Prints process tree of user 'user' processes.
pstree -p user
Change directory to "/path/to/pdf"
cd /path/to/pdf
display all the files in the current folder that are at least one week old (7 days) but less then 30 days old
find . -mtime +30 -a -mtime -7 -print0
Find files/directories named 'foo' in the current partition of the root filesystem
find -x / -name foo
Search the regular files of the current directory tree for string "foo"
find ./ -type f | xargs grep "foo"
Find all files/directories under current directory and print their paths
find . -exec echo {} \;
Finds matched text in defined path recursively, but not follows symlinks.
grep -r "string to be searched" /path/to/dir
Find recursively the files named "file" in the current directory ignoring all .git directories
find . -name .git -prune -o -name file -print
find all regular/normal files in current folder which have been modified in the last 60 minutes
find -type f -mtime -60
display all the files in the current folder excluding the file states_to_csv.pl and those that are present in the directories whose name starts with ".git"
find . \! -path "./.git*" -a \! -name states_to_csv.pl
Display bash function definition of "foobar"
set | sed -n '/^foobar ()/,/^}/p'
change the permissions of all the regular/normal files in the current folder
sudo find . -type f -exec chmod 644 {} +
find all the log files in the file system
find / -name "*.log"
Find all files under current directory whose status was changed less than 3 days ago and show last 5 lines of output
find . -type f -ctime -3 | tail -n 5
List all entry names contained directly by directory in_save in the current directory, pausing for user input at each page.
find ./in_save/ -type f -maxdepth 1| more
Find all files in your home directory and below that are exactly 100M.
find ~ -size 100M
Find the passwd file under root and two levels down
find / -maxdepth 3 -name passwd
list symbolic links under the directory "$directory" using contents of the $IFS variable between output of each one
find $directory -type l -printf "%p$IFS"
Connect to host 'hostname' as user 'username' by forcing host key confirmation
ssh -o UserKnownHostsFile=/dev/null username@hostname
List all aliencoders.[0-9]+ files/directories under /home/jassi/ directory
find /home/jassi/ -name "aliencoders.[0-9]+" |& xargs ls -lrt | awk '{print $9}'
Recursively finds strings with 'word-1' or 'word-2' in any file under 'directory-path', following symlinks, and prints found strings.
egrep -R "word-1|word-2” directory-path
search for a word in all the .C files in current directory
find . -type f \ |grep -i -r “keyword”
Change folder to the one where $0 link target file is located.
cd $(dirname $)
Find all files with extension .aac in the /home directory tree
find /home -type f -name '*.aac'
Report root file system disk usage human-readable.
df -h /
search for the file "process.txt" in the current directory
find . -name "process.txt"
Search for files/directories named 'fileName.txt' under '/path/to/folder' directory tree without traversing into directories that contain the string 'ignored_directory' in their paths
find /path/to/folder -path "*/ignored_directory" -prune -o -name fileName.txt -print
Find all empty files in the current directory and delete them
find . -empty -maxdepth 1 -exec rm {} \;
Save actual working directory in variable "target_PWD"
target_PWD=$
display all the files in the current folder which have been modified in the last 5*24 hours
find . -mtime -5
Find files in the current directory tree which are larger than 5 MB in size
find . -size +5000k -type f
Archive files (not directories) in "sorce_dir" to "target_dir"
rsync -a --filter="-! */" sorce_dir/ target_dir/
Change the owner of "/var/www/html/mysite/tmp_file_upload/" to "nobody"
sudo chown nobody /var/www/html/mysite/tmp_file_upload/