Category Archives: File & Directory

In Linux/Unix, a tutorial on using file and directory commands such as ls, mkdir, mv, etc.

grep command tutorial in linux/unix with examples and use cases

linux grep command – print lines that match patterns Linux grep searches for PATTERNS in each FILE. PATTERNS is one or patterns separated by newline characters, and grep prints each line that matches a pattern. A FILE of “-” stands … Continue reading

Posted in File & Directory | Tagged , , | Comments Off on grep command tutorial in linux/unix with examples and use cases

tee command tutorial in linux/unix with examples and use cases

linux tee command – read from standard input and write to standard output and files. Copy standard input to each FILE, and also to standard output. Continue reading

Posted in File & Directory | Tagged | Comments Off on tee command tutorial in linux/unix with examples and use cases

How to replace strings in files in the Linux command line

There are many ways to replace strings in Linux. You can use vim/vi to edit files, you can also use the sed command to replace, or you can search for all files to be replaced and replace them. Continue reading

Posted in How to, File & Directory, Sed Command, Text Processing, Vim Command | Tagged , , | Comments Off on How to replace strings in files in the Linux command line

more command tutorial in linux/unix with examples and use cases

linux more command – a filter for paging through text one screenful at a time. Examples: Display file contents starting at line 20, search for strings in files and display … Continue reading

Posted in File & Directory | Tagged , , | Comments Off on more command tutorial in linux/unix with examples and use cases

Create a file in linux, you can do this!

Create a file in linux, Examples:
use the linux touch command create an empty file;
use the linux vim/vi command;
use the linux cp command;
use the redirect “>” or “>>”. Continue reading

Posted in File & Directory, How to | Tagged , | Comments Off on Create a file in linux, you can do this!

How to display the first line and the last few lines of a file in Linux

In linux, print the first line and the last few lines of the file. Print the first line and the last 10 lines of the file.Print the first line of the file and the last 10 to 15 lines of the file Continue reading

Posted in How to, File & Directory | Tagged , , | 1 Comment

How to count the number of lines of file in Linux

In Linux, Count the total lines number,Count the total number of non repeating lines,Count the total number of duplicate lines,Count the number of times specific content Continue reading

Posted in File & Directory, How to | Tagged , | Comments Off on How to count the number of lines of file in Linux

uniq command tutorial in linux/unix with examples and use cases

linux uniq command – report or omit repeated lines. Which usually requires sorted input, compares and ranks only on adjacent lines. Continue reading

Posted in File & Directory | Tagged , | Comments Off on uniq command tutorial in linux/unix with examples and use cases

sort command tutorial in linux/unix with examples and use cases

linux sort command – sort lines of text files.examples:separate fields and sort by key, sort file, sort file/directory sizes in human readable format, sort multi column sort Continue reading

Posted in File & Directory | Tagged , , | Comments Off on sort command tutorial in linux/unix with examples and use cases

How to find and delete old linux files or directories

linux delete old files script,linux delete old files by date,linux delete old files cron, scheduled task delete files older than,find and delete files older than X days Continue reading

Posted in File & Directory, How to | Tagged , , | Comments Off on How to find and delete old linux files or directories

How to using multiple delimiters in awk and sed

Multiple delimiter-separated fields in awk or sed.
Using awk command:
➜ awk -F'[:=|]’ ‘{print $1, $2, $3}’ test.log;
Using sed command:
➜ sed ‘s/[:=|]/ /g’ test.log Continue reading

Posted in Awk Command, File & Directory, How to, Sed Command, Text Processing | Tagged , , , , , , | 3 Comments

mv command tutorial in linux/unix with examples and use cases

linux mv command – move (rename) files or directories. Examples:Move multiple files,move just files, move overwrite files and backup,move multiple files … Continue reading

Posted in File & Directory | Tagged , , | Comments Off on mv command tutorial in linux/unix with examples and use cases

cp command tutorial in linux/unix with examples and use cases

linux cp command – copy files or group of files or directories. Examples:Copy a file, Copy multiple files to directory, Copy directory and files, using option -p … Continue reading

Posted in File & Directory | Tagged , , | Comments Off on cp command tutorial in linux/unix with examples and use cases

How to search all files with specific text on Linux?

How to search all files with specific content in Linux system? Use the grep to search for specific content, Use the find and grep to search for specified… Continue reading

Posted in File & Directory, How to | Tagged , , | Comments Off on How to search all files with specific text on Linux?

head command tutorial in linux/unix with examples and use cases

Linux head command – output the first part of files. Print the first 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. Continue reading

Posted in File & Directory | Tagged , , | Comments Off on head command tutorial in linux/unix with examples and use cases