Category Archives: File & Directory

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

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

linux cat command – concatenate files and print on the standard output. This article shares the syntax, options, and usage examples for the cat command. Continue reading

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

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

linux tail command – output the last part of files, it corresponds to the linux head command. This article introduces the tail syntax, options, and examples. Continue reading

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

rename file linux – use rename cmd or mv cmd or awk cmd

Rename file in linux has two ways: linux rename command and linux mv command. linux rename command rename command – renames multiple files. Ubuntu is used as the test system, it does not have the remanae command installed by default. … Continue reading

Posted in File & Directory, Awk Command, Internet Technology | Tagged , , | 2 Comments

ls only files or directories examples in linux

linux ls only directory:
➜ ls -d */ ;
➜ ls -l | grep “^d” ;
➜ find . -type d -maxdepth 1;

linux ls only files:
➜ ls -l | grep “^-” ;
➜ find ./ -type f … Continue reading

Posted in File & Directory | Tagged , , | Comments Off on ls only files or directories examples in linux

How to sort by size, type, time, name using linux ls command

Linux ls command can use command options to sort files or directories. This article describes: ls sort by size, ls sort by time, ls sort by name, ls sort by type Continue reading

Posted in File & Directory, How to | Tagged , , , | Comments Off on How to sort by size, type, time, name using linux ls command

How to split large files by line or by file size in Linux

When Linux splits large files, we usually use the linux split command to split files by line or by size.
When you split the file, also need to use the split of the string. Continue reading

Posted in File & Directory, How to | Tagged , , | Comments Off on How to split large files by line or by file size in Linux

grep multiple words/patterns/strings, and/or condition, use -e or regex

grep multiple words

You can use grep -e parameters and pipes (“|”) to implement grep multiple words “and” query, “or” query … Continue reading

Posted in File & Directory | Tagged , , | Comments Off on grep multiple words/patterns/strings, and/or condition, use -e or regex

linux grep process by name/by id and kill example, and grep -v example

linux grep process

– grep process name;
– grep process by port;
– grep process id and kill;
– grep process without itself;
– grep process without grep
Continue reading

Posted in File & Directory | Tagged , , , | Comments Off on linux grep process by name/by id and kill example, and grep -v example

How to count using the grep command in Linux/Unix

linux grep count * ; – grep count lines; – grep count words; – grep count files; – grep count sort; – grep two words on the same line …… Continue reading

Posted in File & Directory, How to | Tagged , , | Comments Off on How to count using the grep command in Linux/Unix

linux grep command – grep not include, grep reverse match

There is also a case where we need to exclude certain content when we do content search. How to achieve it? Still linux grep command! I have such a file test5.txt. Need to query the line containing “dfff” content but … Continue reading

Posted in File & Directory | Tagged , , | Comments Off on linux grep command – grep not include, grep reverse match

linux grep command – grep only show match

When we search for content, sometimes we just need to show matching content. At this time we can use the grep command. linux grep You can also display the line number where the matching content is located. linux grep -n … Continue reading

Posted in File & Directory | Tagged , , , | Comments Off on linux grep command – grep only show match

Linux Location and File Finding Command

linux locate Syntax Explain Linux locate command is used to find eligible documents or directories in the database. When locate is first executed, it establishes an index database, and when it is executed again later, it quickly locates files from … Continue reading

Posted in File & Directory | Tagged , , , | Comments Off on Linux Location and File Finding Command

linux grep command – grep multiple patterns

The last article 《grep or condition, grep and condition》 introduced grep and, or use, including the use of the -e parameter. Here is a detailed description of the use of the -e parameter. grep one pattern ➜ grep “12” test1.txt … Continue reading

Posted in File & Directory | Tagged , , , | Comments Off on linux grep command – grep multiple patterns

grep show lines before and after

Usually when searching for keywords, we need to look at the keyword context information, all of which use -A, -B and -C parameters. Show num rows after matching – grep -A Show num rows before matching – grep -B Show … Continue reading

Posted in File & Directory | Tagged , , | Comments Off on grep show lines before and after

linux grep or , grep and , grep not condition examples

Linux grep conditional;

Grep OR:
1. Use regular, grep -E “[A|B]”;
2. Use -e,grep -e “A” -e “B”;

Grep AND:
Use pipe, grep “A” | grep “B”;

Grep NOT: use grep -v Continue reading

Posted in File & Directory | Tagged , , , | Comments Off on linux grep or , grep and , grep not condition examples