reworking content
All checks were successful
learn org at code.softwareshinobi.com/linux.softwareshinobi.com/pipeline/head This commit looks good
All checks were successful
learn org at code.softwareshinobi.com/linux.softwareshinobi.com/pipeline/head This commit looks good
This commit is contained in:
153
landing/docs/Commands/files/cat.md
Normal file
153
landing/docs/Commands/files/cat.md
Normal file
@@ -0,0 +1,153 @@
|
||||
# The `cat` command
|
||||
---
|
||||
|
||||
The `cat` command allows us to create single or multiple files, to view the content of a file or to concatenate files and redirect the output to the terminal or files.
|
||||
|
||||
The "cat" stands for 'concatenate.' and it's one of the most frequently used commands in the Linux terminal.
|
||||
|
||||
|
||||
### Examples of uses:
|
||||
|
||||
|
||||
1. To display the content of a file in terminal:
|
||||
|
||||
```
|
||||
cat <specified_file_name>
|
||||
```
|
||||
|
||||
2. To display the content of multiple files in terminal:
|
||||
|
||||
```
|
||||
cat file1 file2 ...
|
||||
```
|
||||
|
||||
3. To create a file with the cat command:
|
||||
|
||||
```
|
||||
cat > file_name
|
||||
```
|
||||
|
||||
4. To display all files in current directory with the same filetype:
|
||||
|
||||
```
|
||||
cat *.<filetype>
|
||||
```
|
||||
|
||||
5. To display the content of all the files in current directory:
|
||||
|
||||
```
|
||||
cat *
|
||||
```
|
||||
|
||||
6. To put the output of a given file into another file:
|
||||
|
||||
```
|
||||
cat old_file_name > new_file_name
|
||||
```
|
||||
7. Use cat command with `more` and `less` options:
|
||||
|
||||
```
|
||||
cat filename | more
|
||||
cat filename | less
|
||||
```
|
||||
|
||||
8. Append the contents of file1 to file2:
|
||||
|
||||
```
|
||||
cat file1 >> file2
|
||||
```
|
||||
|
||||
9. To concatenate two files together in a new file:
|
||||
|
||||
```
|
||||
cat file1_name file2_name merge_file_name
|
||||
```
|
||||
|
||||
10. Some implementations of cat, with option -n, it's possible to show line numbers:
|
||||
|
||||
```
|
||||
cat -n file1_name file2_name > new_numbered_file_name
|
||||
```
|
||||
|
||||
|
||||
### Syntax:
|
||||
|
||||
```
|
||||
cat [OPTION] [FILE]...
|
||||
```
|
||||
|
||||
### Additional Flags and their Functionalities:
|
||||
|
||||
|**Short Flag** |**Long Flag** |**Description** |
|
||||
|:---|:---|:---|
|
||||
|`-A`| `--show-all` |equivalent to -vET|
|
||||
|`-b`| `--number-nonblank` |number nonempty output lines, overrides -n|
|
||||
|`-e`|<center>-</center>| equivalent to -vE|
|
||||
|`-T`|<center>-</center>|Display tab separated lines in file opened with ```cat``` command.|
|
||||
|`-E`|<center>-</center>|To show $ at the end of each file.|
|
||||
|`-E`|<center>-</center>|Display file with line numbers.|
|
||||
|`-n`| `--number`|number all output lines|
|
||||
|`-s`| `--squeeze-blank`|suppress repeated empty output lines|
|
||||
|`-u`|<center>-</center>|(ignored)|
|
||||
|`-v`| `--show-nonprinting`|use ^ and M- notation, except for LFD and TAB|
|
||||
|<center>-</center>|`--help` |display this help and exit|
|
||||
|<center>-</center>|`--version`|output version information and exit|
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
# The `tac` command
|
||||
|
||||
`tac` is a Linux command that allows you to view files line-by-line, beginning from the last line. (tac doesn't reverse the contents of each individual line, only the order in which the lines are presented.) It is named by analogy with `cat`.
|
||||
|
||||
|
||||
### Examples of uses:
|
||||
|
||||
|
||||
1. To display the content of a file in terminal:
|
||||
|
||||
```
|
||||
tac <specified_file_name>
|
||||
```
|
||||
|
||||
2. This option attaches the separator before instead of after.
|
||||
|
||||
```
|
||||
tac -b concat_file_name tac_example_file_name
|
||||
```
|
||||
3. This option will interpret the separator as a regular expression.
|
||||
```
|
||||
tac -r concat_file_name tac_example_file_name
|
||||
```
|
||||
4. This option uses STRING as the separator instead of newline.
|
||||
```
|
||||
tac -s concat_file_name tac_example_file_name
|
||||
```
|
||||
|
||||
5. This option will display the help text and exit.
|
||||
|
||||
```
|
||||
tac --help
|
||||
```
|
||||
6. This option will give the version information and exit.
|
||||
|
||||
```
|
||||
tac --version
|
||||
```
|
||||
|
||||
### Syntax:
|
||||
|
||||
```
|
||||
tac [OPTION]... [FILE]...
|
||||
```
|
||||
|
||||
### Additional Flags and their Functionalities:
|
||||
|
||||
|**Short Flag** |**Long Flag** |**Description** |
|
||||
|:---|:---|:---|
|
||||
|`-b`|`--before`|attach the separator before instead of after|
|
||||
|`-r`| `--regex`|interpret the separator as a regular expression|
|
||||
|`-s`| `--separator=STRING`|use STRING as the separator instead of newline|
|
||||
|<center>-</center>|`--help`|display this help and exit|
|
||||
|<center>-</center>|`--version`|output version information and exit|
|
||||
103
landing/docs/Commands/files/cp.md
Normal file
103
landing/docs/Commands/files/cp.md
Normal file
@@ -0,0 +1,103 @@
|
||||
# The `cp` command
|
||||
|
||||
The `cp` is a command-line utility for copying files and directory.
|
||||
`cp` stands for copy. This command is used to copy files or group of files or directory. It creates an exact image of a file on a disk with different file name. The cp command requires at least two filenames in its arguments.
|
||||
|
||||
### Examples:
|
||||
|
||||
1. To copy the contents of the source file to the destination file.
|
||||
|
||||
```
|
||||
cp sourceFile destFile
|
||||
```
|
||||
|
||||
If the destination file doesn't exist then the file is created and the content is copied to it. If it exists then the file is overwritten.
|
||||
|
||||
2. To copy a file to another directory specify the absolute or the relative path to the destination directory.
|
||||
|
||||
```
|
||||
cp sourceFile /folderName/destFile
|
||||
```
|
||||
|
||||
3. To copy a directory, including all its files and subdirectories
|
||||
|
||||
```
|
||||
cp -R folderName1 folderName2
|
||||
```
|
||||
|
||||
The command above creates the destination directory and recursively copies all files and subdirectories from the source to the destination directory.
|
||||
|
||||
If the destination directory already exists, the source directory itself and its content are copied inside the destination directory.
|
||||
|
||||
4. To copy only the files and subdirectories but not the source directory
|
||||
|
||||
```
|
||||
cp -RT folderName1 folderName2
|
||||
```
|
||||
|
||||
### Syntax:
|
||||
|
||||
The general syntax for the cp command is as follows:
|
||||
|
||||
```
|
||||
cp [OPTION] SOURCE DESTINATION
|
||||
cp [OPTION] SOURCE DIRECTORY
|
||||
cp [OPTION] SOURCE-1 SOURCE-2 SOURCE-3 SOURCE-n DIRECTORY
|
||||
```
|
||||
|
||||
The first and second syntax is used to copy Source file to Destination file or Directory.
|
||||
The third syntax is used to copy multiple Sources(files) to Directory.
|
||||
|
||||
#### Some useful options
|
||||
|
||||
1. `-i` (interactive)
|
||||
`i` stands for Interactive copying. With this option system first warns the user before overwriting the destination file. cp prompts for a response, if you press y then it overwrites the file and with any other option leave it uncopied.
|
||||
|
||||
```
|
||||
$ cp -i file1.txt fileName2.txt
|
||||
cp: overwrite 'file2.txt'? y
|
||||
```
|
||||
|
||||
2. `-b`(backup)
|
||||
-b(backup): With this option cp command creates the backup of the destination file in the same folder with the different name and in different format.
|
||||
|
||||
```
|
||||
$ ls
|
||||
a.txt b.txt
|
||||
|
||||
$ cp -b a.txt b.txt
|
||||
|
||||
$ ls
|
||||
a.txt b.txt b.txt~
|
||||
```
|
||||
|
||||
3. `-f`(force)
|
||||
If the system is unable to open destination file for writing operation because the user doesn't have writing permission for this file then by using -f option with cp command, destination file is deleted first and then copying of content is done from source to destination file.
|
||||
```
|
||||
$ ls -l b.txt
|
||||
-r-xr-xr-x+ 1 User User 3 Nov 24 08:45 b.txt
|
||||
```
|
||||
User, group and others doesn't have writing permission.
|
||||
|
||||
Without `-f` option, command not executed
|
||||
|
||||
```
|
||||
$ cp a.txt b.txt
|
||||
cp: cannot create regular file 'b.txt': Permission denied
|
||||
```
|
||||
|
||||
With -f option, command executed successfully
|
||||
```
|
||||
$ cp -f a.txt b.txt
|
||||
```
|
||||
|
||||
### Additional Flags and their Functionalities:
|
||||
|
||||
|**Short Flag** |**Long Flag** |**Description** |
|
||||
|:---|:---|:---|
|
||||
|`-i`|<center>--interactive</center>|prompt before overwrite|
|
||||
|`-f`|<center>--force</center>|If an existing destination file cannot be opened, remove it and try again|
|
||||
|`-b`|<center>-</center>|Creates the backup of the destination file in the same folder with the different name and in different format.|
|
||||
|`-r or -R`|`--recursive`|**cp** command shows its recursive behavior by copying the entire directory structure recursively.|
|
||||
|`-n`|`--no-clobber`|do not overwrite an existing file (overrides a previous -i option)|
|
||||
|`-p`|<center>-</center>|preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, xattr, all|
|
||||
48
landing/docs/Commands/files/diff.md
Normal file
48
landing/docs/Commands/files/diff.md
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
# The `diff/sdiff` command
|
||||
This command is used to display the differences in the files by comparing the files line by line.
|
||||
### Syntax:
|
||||
|
||||
```
|
||||
diff [options] File1 File2
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
1. Lets say we have two files with names a.txt and b.txt containing 5 Indian states as follows-:
|
||||
```
|
||||
$ cat a.txt
|
||||
Gujarat
|
||||
Uttar Pradesh
|
||||
Kolkata
|
||||
Bihar
|
||||
Jammu and Kashmir
|
||||
|
||||
$ cat b.txt
|
||||
Tamil Nadu
|
||||
Gujarat
|
||||
Andhra Pradesh
|
||||
Bihar
|
||||
Uttar pradesh
|
||||
|
||||
```
|
||||
On typing the diff command we will get below output.
|
||||
```
|
||||
$ diff a.txt b.txt
|
||||
0a1
|
||||
> Tamil Nadu
|
||||
2,3c3
|
||||
< Uttar Pradesh
|
||||
Andhra Pradesh
|
||||
5c5
|
||||
Uttar pradesh
|
||||
```
|
||||
|
||||
### Flags and their Functionalities
|
||||
|
||||
|**Short Flag** |**Description** |
|
||||
|--|--|
|
||||
| `-c`|To view differences in context mode, use the -c option. |
|
||||
| `-u`|To view differences in unified mode, use the -u option. It is similar to context mode |
|
||||
|`-i`|By default this command is case sensitive. To make this command case in-sensitive use -i option with diff. |
|
||||
|`-version`|This option is used to display the version of diff which is currently running on your system. |
|
||||
44
landing/docs/Commands/files/dir.md
Normal file
44
landing/docs/Commands/files/dir.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# The `dir` command
|
||||
|
||||
The `dir` command lists the contents of a directory(_the current directory by default_). **It differs from ls command in the format of listing the content**. By default, the dir command lists the files and folders in columns, sorted vertically and special characters are represented by backslash escape sequences.
|
||||
|
||||
### Syntax:
|
||||
|
||||
```[linux]
|
||||
dir [OPTIONS] [FILE]
|
||||
```
|
||||
|
||||
### Examples:
|
||||
|
||||
1. To list files in the current directory:
|
||||
|
||||
```[linux]
|
||||
dir
|
||||
```
|
||||
|
||||
2. To list even the hidden files in the current directory:
|
||||
|
||||
```[linux]
|
||||
dir -a
|
||||
```
|
||||
|
||||
3. To list the content with detailed information for each entry
|
||||
|
||||
```[linux]
|
||||
dir -l
|
||||
```
|
||||
|
||||
### Additional Flags and their Functionalities:
|
||||
|
||||
| **Short Flag** | **Long Flag** | **Description** |
|
||||
| :----------------- | :-------------------------- | :-------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `-a` | `--all` | It displays all the hidden files(starting with `.`) along with two files denoted by `.` and `..` |
|
||||
| `-A` | `--almost-all` | It is **similar to -a** option except that it _does not display files that signals the current directory and previous directory._ |
|
||||
| `-l` | <center>-</center> | Display detailed information for each entry |
|
||||
| `-s` | `--size` | Print the allocated size of each file, in blocks File |
|
||||
| `-h` | `--human-readable` | Used with with -l and -s, to print sizes like in human readable format like 1K, 2M and so on |
|
||||
| `-F` | <center>-</center> | Classifies entries into their type based on appended symbol (`/`, `*`, `@`, `%`, `=`) |
|
||||
| `-v` | `--verbose` | Print source and destination files |
|
||||
| <center>-</center> | `--group-directories-first` | To group directories before files |
|
||||
| `-R ` | `--recursive` | To List subdirectories recursively. |
|
||||
| `-S ` | <center>-</center> | sort by file size, display largest first |
|
||||
37
landing/docs/Commands/files/du.md
Normal file
37
landing/docs/Commands/files/du.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# The `du` command
|
||||
|
||||
The `du` command, which is short for `disk usage` lets you retrieve information about disk space usage information in a specified directory. In order to customize the output according to the information you need, this command can be paired with the appropriate options or flags.
|
||||
|
||||
### Examples:
|
||||
|
||||
1. To show the estimated size of sub-directories in the current directory:
|
||||
|
||||
```
|
||||
du
|
||||
```
|
||||
|
||||
2. To show the estimated size of sub-directories inside a specified directory:
|
||||
|
||||
```
|
||||
du {PATH_TO_DIRECTORY}
|
||||
```
|
||||
|
||||
### Syntax:
|
||||
|
||||
```
|
||||
du [OPTION]... [FILE]...
|
||||
du [OPTION]... --files0-from=F
|
||||
```
|
||||
|
||||
### Additional Flags and their Functionalities:
|
||||
|
||||
*Note: This does not include an exhaustive list of options.*
|
||||
|
||||
|**Short Flag** |**Long Flag** |**Description** |
|
||||
|:---|:---|:---|
|
||||
|`-a`|`--all`|Includes information for both files and directories|
|
||||
|`-c`|`--total`|Provides a grand total at the end of the list of files/directories|
|
||||
|`-d`|`--max-depth=N`|Provides information up to `N` levels from the directory where the command was executed|
|
||||
|`-h`|`--human-readable`|Displays file size in human-readable units, not in bytes|
|
||||
|`-s`|`--summarize`|Display only the total filesize instead of a list of files/directories|
|
||||
|
||||
70
landing/docs/Commands/files/find.md
Normal file
70
landing/docs/Commands/files/find.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# The `find` command
|
||||
|
||||
The `find` command lets you **search for files in a directory hierarchy**
|
||||
|
||||
- Search a file with specific name.
|
||||
- Search a file with pattern
|
||||
- Search for empty files and directories.
|
||||
|
||||
|
||||
### Examples:
|
||||
|
||||
1. Search a file with specific name:
|
||||
|
||||
```[linux]
|
||||
find ./directory1 -name sample.txt
|
||||
```
|
||||
|
||||
2. Search a file with pattern:
|
||||
|
||||
```[linux]
|
||||
find ./directory1 -name '*.txt'
|
||||
```
|
||||
|
||||
3. To find all directories whose name is test in / directory.
|
||||
|
||||
```[linux]
|
||||
find / -type d -name test
|
||||
```
|
||||
|
||||
4. Searching empty files in current directory
|
||||
|
||||
```[linux]
|
||||
find . -size 0k
|
||||
```
|
||||
|
||||
### Syntax:
|
||||
|
||||
```[linux]
|
||||
find [options] [paths] [expression]
|
||||
```
|
||||
**In Simple words**
|
||||
```[linux]
|
||||
find [where to start searching from]
|
||||
[expression determines what to find] [-options] [what to find]
|
||||
```
|
||||
|
||||
### Additional Flags and their Functionalities:
|
||||
|
||||
Commonly-used primaries include:
|
||||
- `name` pattern - tests whether the file name matches the shell-glob pattern given.
|
||||
- `type` type - tests whether the file is a given type. Unix file types accepted include:
|
||||
|
||||
| **options** | **Description** |
|
||||
| :------------- | :-------------------------------------------------------------------------------------------------------- |
|
||||
| `b` | block device (buffered) |
|
||||
| `d` | directory |
|
||||
| `f` | regular file |
|
||||
| `l` | Symbolic link |
|
||||
| `-print` | always returns true; prints the name of the current file plus a newline to the stdout. |
|
||||
| `-mtime n` | find's all the files which are modified n days back. |
|
||||
| `-atime n` | find's all the files which are accessed 50 days back. |
|
||||
| `-cmin n` | find's all the files which are modified in the last 1 hour.|
|
||||
| ` -newer file` | find's file was modified more recently than file.|
|
||||
| `-size n` | File uses n units of space, rounding up.|
|
||||
|
||||
### Help Command
|
||||
Run below command to view the complete guide to `find` command or [click here](https://en.wikipedia.org/wiki/Find_(Unix)).
|
||||
```[linux]
|
||||
man find
|
||||
```
|
||||
62
landing/docs/Commands/files/grep.md
Normal file
62
landing/docs/Commands/files/grep.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# The `grep` command
|
||||
|
||||
The `grep` filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern.
|
||||
grep stands for globally search for regular expression and print out. The pattern that is searched in the file is referred to as the regular expression.
|
||||
|
||||
### Examples:
|
||||
|
||||
1. To search the contents of the destination.txt file for a string("KeY") case insensitively.
|
||||
|
||||
```
|
||||
grep -i "KeY" destination.txt
|
||||
```
|
||||
|
||||
2. Displaying the count of number of matches
|
||||
|
||||
```
|
||||
grep -c "key" destination.txt
|
||||
```
|
||||
|
||||
3. We can search multiple files and only display the files that contains the given string/pattern.
|
||||
|
||||
```
|
||||
grep -l "key" destination1.txt destination2.txt destination3.xt destination4.txt
|
||||
```
|
||||
|
||||
4. To show the line number of file with the line matched.
|
||||
|
||||
```
|
||||
grep -n "key" destination.txt
|
||||
```
|
||||
|
||||
5. If you want to grep the monitored log files, you can add the `--line-buffered` to search them in real time.
|
||||
|
||||
```
|
||||
tail -f destination.txt | grep --line-buffered "key"
|
||||
```
|
||||
|
||||
### Syntax:
|
||||
|
||||
The general syntax for the grep command is as follows:
|
||||
|
||||
```
|
||||
grep [options] pattern [files]
|
||||
```
|
||||
|
||||
### Additional Flags and their Functionalities:
|
||||
|
||||
| **Short Flag** | **Long Flag** | **Description** |
|
||||
| :------------- | :--------------------- | :---------------------------------------------------------------------------------------------- |
|
||||
| `-c` | `--count` | print a count of matching lines for each input file |
|
||||
| `-h` | `--no-filename` | Display the matched lines, but do not display the filenames |
|
||||
| `-i` | `--ignore-case` | Ignores, case for matching |
|
||||
| `-l` | `--files-with-matches` | Displays list of a filenames only. |
|
||||
| `-n` | `--line-number` | Display the matched lines and their line numbers. |
|
||||
| `-v` | `--invert-match` | This prints out all the lines that do not matches the pattern |
|
||||
| `-e` | `--regexp=` | Specifies expression with this option. Can use multiple times |
|
||||
| `-f` | `--file=` | Takes patterns from file, one per line. |
|
||||
| `-F` | `--fixed-strings=` | Interpret patterns as fixed strings, not regular expressions. |
|
||||
| `-E` | `--extended-regexp` | Treats pattern as an extended regular expression (ERE) |
|
||||
| `-w` | `--word-regexp` | Match whole word |
|
||||
| `-o` | `--only-matching` | Print only the matched parts of a matching line, with each such part on a separate output line. |
|
||||
| | `--line-buffered` | Force output to be line buffered. |
|
||||
41
landing/docs/Commands/files/head.md
Normal file
41
landing/docs/Commands/files/head.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# The `head` command
|
||||
|
||||
The `head` command prints the first ten lines of a file.
|
||||
|
||||
Example:
|
||||
```
|
||||
head filename.txt
|
||||
```
|
||||
|
||||
Syntax:
|
||||
```
|
||||
head [OPTION] [FILENAME]
|
||||
```
|
||||
|
||||
### Get a specific number of lines:
|
||||
|
||||
Use the `-n` option with a number (should be an integer) of lines to display.
|
||||
|
||||
Example:
|
||||
```
|
||||
head -n 10 foo.txt
|
||||
```
|
||||
|
||||
This command will display the first ten lines of the file `foo.txt`.
|
||||
|
||||
Syntax:
|
||||
```
|
||||
head -n <number> foo.txt
|
||||
```
|
||||
### Additional Flags and their Functionalities
|
||||
|
||||
|
||||
|**Short Flag** |**Long Flag** |**Description** |
|
||||
|:---|:---|:---|
|
||||
|`-c`|`--bytes=[-]NUM`|Print the first NUM bytes of each file; <br>with the leading '-', <br>print all but the last NUM bytes of each file|
|
||||
|`-n`|`--lines=[-]NUM`|Print the first NUM lines instead of the first 10;<br> with the leading '-', <br>print all but the last NUM lines of each file|
|
||||
|`-q`|`--quiet, --silent`|Never print headers giving file names|
|
||||
|`-v`|`--verbose`|Always print headers giving file names|
|
||||
|`-z`|`--zero-terminated`|Line delimiter is NUL, not newline|
|
||||
|` `|`--help`| Display this help and exit|
|
||||
|` `|`--version`|Output version information and exit|
|
||||
71
landing/docs/Commands/files/ls.md
Normal file
71
landing/docs/Commands/files/ls.md
Normal file
@@ -0,0 +1,71 @@
|
||||
# The `ls` command
|
||||
|
||||
The `ls` command lets you see the files and directories inside a specific directory *(current working directory by default)*.
|
||||
It normally lists the files and directories in ascending alphabetical order.
|
||||
|
||||
### Examples:
|
||||
|
||||
1. To show the files inside your current working directory:
|
||||
|
||||
```
|
||||
ls
|
||||
```
|
||||
|
||||
2. To show the files and directory inside a specific Directory:
|
||||
|
||||
```
|
||||
ls {Directory_Path}
|
||||
```
|
||||
|
||||
### Syntax:
|
||||
|
||||
```
|
||||
ls [-OPTION] [DIRECTORY_PATH]
|
||||
```
|
||||
|
||||
### Interactive training
|
||||
|
||||
In this interactive tutorial, you will learn the different ways to use the `ls` command:
|
||||
|
||||
[The ls command by Tony](https://devdojo.com/tnylea/ls-command)
|
||||
|
||||
### Additional Flags and their Functionalities:
|
||||
|
||||
|**Short Flag** |**Long Flag** |**Description** |
|
||||
|:---|:---|:---|
|
||||
|`-l`|<center>-</center>|Show results in long format|
|
||||
|`-S`|<center>-</center>|Sort results by file size|
|
||||
|`-t`|<center>-</center>|Sort results by modification time|
|
||||
|`-r`|`--reverse`|Show files and directories in reverse order *(descending alphabetical order)*|
|
||||
|`-a`|`--all`|Show all files, including hidden files *(file names which begin with a period `.`)*|
|
||||
|`-la`|<center>-</center>|Show long format files and directories including hidden files|
|
||||
|`-lh`|<center>-</center>|list long format files and directories with readable size|
|
||||
|`-A`|`--almost-all`|Shows all like `-a` but without showing `.`(current working directory) and `..` (parent directory)|
|
||||
|`-d`|`--directory`|Instead of listing the files and directories inside the directory, it shows any information about the directory itself, it can be used with `-l` to show long formatted information|
|
||||
|`-F`|`--classify`|Appends an indicator character to the end of each listed name, as an example: `/` character is appended after each directory name listed|
|
||||
|`-h`|`--human-readable`|like `-l` but displays file size in human-readable unit not in bytes|
|
||||
|
||||
|
||||
### Setting Persistent Options:
|
||||
|
||||
|
||||
Customizing command behavior in Linux is easy using the `alias` command. To make these changes permanent, follow these steps:
|
||||
|
||||
1. **Create the Alias**: Define your alias with the desired options. For example, to enhance the `ls` command:
|
||||
|
||||
```bash
|
||||
alias ls="ls --color=auto -lh"
|
||||
```
|
||||
|
||||
2. **Persistence**: This alias is effective only for the current session. To make it permanent, add the alias to your shell's configuration file:
|
||||
|
||||
- **Bash**: Append the alias to `~/.bashrc`:
|
||||
|
||||
```bash
|
||||
echo 'alias ls="ls --color=auto -lh"' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
3. **Verification**: Open a new terminal session, and the `ls` command will display files as configured.
|
||||
|
||||
|
||||
44
landing/docs/Commands/files/mkdir.md
Normal file
44
landing/docs/Commands/files/mkdir.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# The `mkdir` command
|
||||
The `mkdir` command in Linux/Unix is used to create a directory.
|
||||
|
||||
|
||||
## Syntax
|
||||
```bash
|
||||
$ mkdir [-m=mode] [-p] [-v] [-Z=context] directory [directory ...]
|
||||
```
|
||||
|
||||
## Examples
|
||||
1. Make a directory named **myfiles**.
|
||||
```bash
|
||||
$ mkdir myfiles
|
||||
```
|
||||
|
||||
2. Create a directory named **myfiles** at the home directory:
|
||||
```bash
|
||||
$ mkdir ~/myfiles
|
||||
```
|
||||
|
||||
3. Create the **mydir** directory, and set its file mode (`-m`) so that all users (`a`) may read (`r`), write (`w`), and execute (`x`) it.
|
||||
```bash
|
||||
$ mkdir -m a=rwx mydir
|
||||
```
|
||||
|
||||
You can also create sub-directories of a directory. It will create the parent directory first, if it doesn't exist.
|
||||
If it already exists, then it move further to create the sub-directories without any error message.
|
||||
|
||||
For directories, this means that any user on the system may view ("read"), and create/modify/delete ("write") files in the directory. Any user may also change to ("execute") the directory, for example with the `cd` command.
|
||||
|
||||
4. Create the directory **/home/test/src/python**. If any of the parent directories **/home**, **/home/test**, or **/home/test/src** do not already exist, they are automatically created.
|
||||
```bash
|
||||
$ mkdir -p /home/test/src/python
|
||||
```
|
||||
|
||||
## Options
|
||||
|**Short Flags**|**Long Flags**|**Descriptions**|
|
||||
|:-|:-|:-|
|
||||
|`-m`|`--mode=MODE`|Set file mode (as in chmod), not `a=rwx - umask`.|
|
||||
|`-p`|`--parents`|No error if existing, make parent directories as needed.|
|
||||
|`-v`|`--verbose`|Print a message for each created directory.|
|
||||
|`-Z`|`--context=CTX`|Set the SELinux security context of each created directory to CTX.|
|
||||
|<center>-</center>|`--help`|Display a help message and exit.|
|
||||
|<center>-</center>|`--version`|Output version information and exit.|
|
||||
46
landing/docs/Commands/files/mv.md
Normal file
46
landing/docs/Commands/files/mv.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# The `mv` command
|
||||
|
||||
The `mv` command lets you **move one or more files or directories** from one place to another in a file system like UNIX.
|
||||
It can be used for two distinct functions:
|
||||
|
||||
- To rename a file or folder.
|
||||
- To move a group of files to a different directory.
|
||||
|
||||
_**Note:** No additional space is consumed on a disk during renaming, and the mv command doesn't provide a prompt for confirmation_
|
||||
|
||||
### Syntax:
|
||||
|
||||
```[linux]
|
||||
mv [options] source (file or directory) destination
|
||||
```
|
||||
|
||||
### Examples:
|
||||
|
||||
1. To rename a file called old_name.txt:
|
||||
|
||||
```[linux]
|
||||
mv old_name.txt new_name.txt
|
||||
```
|
||||
|
||||
2. To move a file called _essay.txt_ from the current directory to a directory called _assignments_ and rename it _essay1.txt_:
|
||||
|
||||
```[linux]
|
||||
mv essay.txt assignments/essay1.txt
|
||||
```
|
||||
|
||||
3. To move a file called _essay.txt_ from the current directory to a directory called _assignments_ without renaming it
|
||||
|
||||
```[linux]
|
||||
mv essay.txt assignments
|
||||
```
|
||||
|
||||
### Additional Flags and their Functionalities:
|
||||
|
||||
| **Short Flag** | **Long Flag** | **Description** |
|
||||
| :------------- | :-------------- | :-------------------------------------------------------------------------------------------------------- |
|
||||
| `-f` | `--force` | Force move by overwriting destination file without prompt |
|
||||
| `-i` | `--interactive` | Interactive prompt before overwrite |
|
||||
| `-u` | `--update` | Move only when the source file is newer than the destination file or when the destination file is missing |
|
||||
| `-n` | `--no-clobber` | Do not overwrite an existing file |
|
||||
| `-v` | `--verbose` | Print source and destination files |
|
||||
| `-b` | `--backup` | Create a Backup of Existing Destination File |
|
||||
51
landing/docs/Commands/files/nano.md
Normal file
51
landing/docs/Commands/files/nano.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# The `nano` command
|
||||
|
||||
The `nano` command lets you create/edit text files.
|
||||
|
||||
### Installation:
|
||||
|
||||
Nano text editor is pre-installed on macOS and most Linux distros. It's an alternative to `vi` and `vim`. To check if it is installed on your system type:
|
||||
|
||||
```
|
||||
nano --version
|
||||
```
|
||||
If you don't have `nano` installed you can do it by using the package manager:
|
||||
|
||||
Ubuntu or Debian:
|
||||
|
||||
```
|
||||
sudo apt install nano
|
||||
```
|
||||
|
||||
### Examples:
|
||||
|
||||
1. Open an existing file, type `nano` followed by the path to the file:
|
||||
|
||||
```
|
||||
nano /path/to/filename
|
||||
```
|
||||
|
||||
2. Create a new file, type `nano` followed by the filename:
|
||||
|
||||
```
|
||||
nano filename
|
||||
```
|
||||
|
||||
3. Open a file with the cursor on a specific line and character use the following syntax:
|
||||
|
||||
```
|
||||
nano +line_number,character_number filename
|
||||
```
|
||||
|
||||
### Overview of some Shortcuts and their Functionalities:
|
||||
|
||||
|**Shortcut** |**Description** |
|
||||
|:---|:---|
|
||||
|`Ctrl + S`|Save current file|
|
||||
|`Ctrl + O`|Offer to write file ("Save as")|
|
||||
|`Ctrl + X`|Close buffer, exit from nano|
|
||||
|`Ctrl + K`|Cut current line into cutbuffer|
|
||||
|`Ctrl + U`|Paste contents of cutbuffer|
|
||||
|`Alt + 6`|Copy current line into cutbuffer|
|
||||
|`Alt + U`|Undo last action|
|
||||
|`Alt + E`| Redo last undone action|
|
||||
36
landing/docs/Commands/files/rm.md
Normal file
36
landing/docs/Commands/files/rm.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# The `rm` command
|
||||
|
||||
`rm` which stands for "remove" is a command used to remove *(delete)* specific files. It can also be used to remove directories by using the appropriate flag.
|
||||
|
||||
### Example:
|
||||
```
|
||||
rm filename.txt
|
||||
```
|
||||
### Syntax
|
||||
```
|
||||
rm [OPTION] [FILE|DIRECTORY]
|
||||
```
|
||||
|
||||
### Flags and their Functionalities:
|
||||
|Short Flag|Long Flag|Description|
|
||||
|:---|:---|:---|
|
||||
|`-f`|`--force`|Ignore nonexistance of files or directories, never prompt|
|
||||
|`-i`|<center>-</center>|Prompt before every removal|
|
||||
|`-I`|<center>-</center>|Prompt once before removal of more than 3 files, or when removing recursively|
|
||||
|`-d`|`--dir`|remove empty directories|
|
||||
|`-v`|`--verbose`|explain what is being done|
|
||||
|`-r` or `-R`|`--recursive`|remove directories and their contents recursively|
|
||||
|<center>-</center>|`--help`|Display help then exit|
|
||||
|<center>-</center>|`--version`|First, Print version Information, Then exit|
|
||||
|<center>-</center>|`--no-preserve-root`|do not treat `/` specially|
|
||||
|<center>-</center>|`-preserve-root[=all]`|do not remove `/` (default) <br>with 'all', reject any command line argument on a separate device from its parent|
|
||||
|<center>-</center>|`--interactive[=WHEN]`|prompt according to WHEN, never, once `-I`, or always `-i`, without WHEN, prompt always|
|
||||
|<center>-</center>|` --one-file-system`|when removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument0|
|
||||
|
||||
|
||||
***IMPORTANT NOTICE:***
|
||||
1. `rm` doesn't remove directories by default, so use `-r`, `-R`, `--recursive` options to remove each listed directory, along with all of its contents.
|
||||
2. To remove a file whose name starts with `-` such as `-foo`, use one of the following commands:
|
||||
- `rm -- -foo`
|
||||
- `rm ./-foo`
|
||||
3. To ensure that files/directories being deleted are truly unrecoverable, consider using the `shred` command.
|
||||
56
landing/docs/Commands/files/tail.md
Normal file
56
landing/docs/Commands/files/tail.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# The `tail` command
|
||||
|
||||
The `tail` command prints the last ten lines of a file.
|
||||
|
||||
Example:
|
||||
```
|
||||
tail filename.txt
|
||||
```
|
||||
|
||||
Syntax:
|
||||
```
|
||||
tail [OPTION] [FILENAME]
|
||||
```
|
||||
|
||||
### Get a specific number of lines with `tail`:
|
||||
|
||||
Use the `-n` option with a number(should be an integer) of lines to display.
|
||||
|
||||
Example:
|
||||
```
|
||||
tail -n 10 foo.txt
|
||||
```
|
||||
|
||||
This command will display the last ten lines of the file `foo.txt`.
|
||||
|
||||
### Refresh the output on any new entry in a file
|
||||
|
||||
It is possible to let tail output any new line added to the file you are looking into. So, if a new line is written to the file, it will immediately be shown in your output. This can be done using the `--follow` or `-f` option. This is especially useful for monitoring log files.
|
||||
|
||||
Example:
|
||||
```
|
||||
tail -f foo.txt
|
||||
```
|
||||
|
||||
Syntax:
|
||||
```
|
||||
tail -n <number> foo.txt
|
||||
```
|
||||
|
||||
### Additional Flags and their Functionalities
|
||||
|
||||
|**Short Flag** |**Long Flag** |**Description** |
|
||||
|:---|:---|:---|
|
||||
|`-c`|`--bytes=[+]NUM`|Output the last NUM bytes;<br> or use -c +NUM to <br>output starting with byte NUM of each file|
|
||||
|`-f`|<code>--follow[={name|descriptor}]</code>|Output appended data as the file grows;<br>an absent option argument means 'descriptor'|
|
||||
|`-F`||Same as --follow=name --retry|
|
||||
|`-n`|`--lines=[+]NUM`|Output the last NUM lines, instead of the last 10;<br>or use -n +NUM to output starting with line NUM|
|
||||
||`--max-unchanged-stats=N`|with --follow=name, reopen a FILE which has not<br>changed size after N (default 5) iterations<br>to see if it has been unlinked or rename<br>(this is the usual case of rotated log files);<br>with inotify, this option is rarely useful|
|
||||
||`--pid=PID`|with -f, terminate after process ID, PID dies|
|
||||
|`-q`|`--quiet, --silent`|Never output headers giving file names|
|
||||
|``|`--retry`|keep trying to open a file if it is inaccessible|
|
||||
|`-s`|`--sleep-interval=N`|With -f, sleep for approximately N seconds<br>(default 1.0) between iterations;<br>with inotify and --pid=P, check process P at<br>least once every N seconds|
|
||||
|`-v`|`--verbose`|Always output headers giving file names|
|
||||
|`-z`|`--zero-terminated`|Line delimiter is NUL, not newline|
|
||||
||`--help`|Display this help and exit|
|
||||
||`--version`|Output version information and exit|
|
||||
59
landing/docs/Commands/files/touch.md
Normal file
59
landing/docs/Commands/files/touch.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# The `touch` Command
|
||||
The `touch` command modifies a file's timestamps. If the file specified doesn't exist, an empty file with that name is created.
|
||||
|
||||
|
||||
### Syntax
|
||||
```
|
||||
touch [OPTION]... FILE...
|
||||
```
|
||||
|
||||
### Options
|
||||
|**Short Flag** |**Long Flag** |**Description** |
|
||||
|:---|:---|:---|
|
||||
|`-a`|<center>-</center>|Change only the access time.|
|
||||
|`-c`|`--no-create`|Do not create any files.|
|
||||
|`-d` STRING|`--date=STRING`|Parse *STRING* and use it instead of the current time.|
|
||||
|`-f`|<center>-</center>|(Ignored) This option does nothing but is accepted to provide compatibility with BSD versions of the `touch` command.|
|
||||
|`-h`|`--no-dereference`|Affect each symbolic link instead of any referenced file (useful only on systems that can change the timestamps of a symlink). This option implies `-c`, nothing is created if the file does not exist.|
|
||||
|`-m`|<center>-</center>|Change only the modification time.|
|
||||
|`-r=FILE`|`--reference=FILE`|Use this file's times instead of the current time.|
|
||||
|`-t STAMP`|<center>-</center>|Use the numeric time *STAMP* instead of the current time. The format of *STAMP* is [[**CC**]**YY**]**MMDDhhmm**[**.ss**].|
|
||||
|<center>-</center>|`--time=WORD`|An alternate way to specify which type of time is set (e.g. *access*, *modification*, or *change*). This is equivalent to specifying `-a` or `-m`.
|
||||
|
||||
- WORD is `access`, `atime`, or `use`: equivalent to `-a`.
|
||||
- WORD is `modify` or `mtime`: equivalent to `-m`.
|
||||
|
||||
An alternate way to specify what type of time to set (as with **-a** and **-m**).|
|
||||
|<center>-</center>|`--help`|Display a help message, and exit.|
|
||||
|<center>-</center>|`--version`|Display version information, and exit.|
|
||||
|
||||
### Examples
|
||||
1. If **file.txt** exists, set all of its timestamps to the current system time. If **file.txt** doesn't exist, create an empty file with that name.
|
||||
```
|
||||
touch file.txt
|
||||
```
|
||||
|
||||
2. If **file.txt** exists, set its times to the current system time. If it does not exist, do nothing.
|
||||
```
|
||||
touch -c file.txt
|
||||
```
|
||||
|
||||
3. Change the *access* time of **file.txt**. The *modification* time is not changed. The *change* time is set to the current system time. If **file.txt** does not exist, it is created.
|
||||
```
|
||||
touch -a file.txt
|
||||
```
|
||||
|
||||
4. Change the times of file **symboliclink**. If it's a symbolic link, change the times of the symlink, ***NOT*** the times of the referenced file.
|
||||
```
|
||||
touch -h symboliclink
|
||||
```
|
||||
|
||||
5. Change the *access* and *modification* times of **file-b.txt** to match the times of **file-a.txt**. The *change* time will be set to the current system time. If **file-b.txt** does not exist, it is not created. Note, **file-a.txt** must already exist in this context.
|
||||
```
|
||||
touch -cr file-a.txt file-b.txt
|
||||
```
|
||||
|
||||
6. Set the *access* time and *modification* time of **file.txt** to ***February 1st*** of the current year. The *change* time is set to the current system time.
|
||||
```
|
||||
touch -d "1 Feb" file.txt
|
||||
```
|
||||
106
landing/docs/Commands/files/vim.md
Normal file
106
landing/docs/Commands/files/vim.md
Normal file
@@ -0,0 +1,106 @@
|
||||
# The `vim` command
|
||||
|
||||
The [vim](https://www.vim.org/) is a text editor for Unix that comes with Linux, BSD, and macOS. It is known to be fast and powerful, partly because it is a small program that can run in a terminal (although it has a graphical interface).
|
||||
Vim text editor is developed by [Bram Moolenaar](https://en.wikipedia.org/wiki/Bram_Moolenaar). It supports most file types and the vim editor is also known as a programmer's editor. It is mainly because it can be managed entirely without menus or a mouse with a keyboard.
|
||||
|
||||
**Note:** Do not confuse `vim` with `vi`. `vi`, which stands for "Visual", is a text editor that was developed by [Bill Joy](https://en.wikipedia.org/wiki/Bill_Joy) in 1976. `vim` stands for "Vi Improved", and is an improved clone of the `vi` editor.
|
||||
|
||||
### The most searched question about ```vim``` :
|
||||
``How to exit vim editor?``
|
||||
|
||||
The most searched question about vim editor looks very funny but it's true that the new user gets stuck at the very beginning when using vim editor.
|
||||
|
||||
The command to save the file and exit vim editor: ```:wq```
|
||||
|
||||
The command to exit vim editor without saving the file: ```:q!```
|
||||
|
||||
#### Fun reading:
|
||||
Here's a [survey](https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/) for the same question, look at this and do not think to quit the vim editor.
|
||||
|
||||
### Installation:
|
||||
First check if vim is already installed or not, enter the following command:
|
||||
```
|
||||
vim --version
|
||||
```
|
||||
If it is already installed it will show its version, else we can run the below commands for the installations:
|
||||
|
||||
On Ubuntu/Debian:
|
||||
|
||||
```
|
||||
sudo apt-get install vim
|
||||
```
|
||||
|
||||
On CentOS/Fedora:
|
||||
|
||||
```
|
||||
sudo yum install vim
|
||||
```
|
||||
If you want to use advanced features on CentOS/Fedora, you'll need to install enhanced vim editor, to do this run the following command:
|
||||
|
||||
```
|
||||
sudo yum install -y vim-enhanced
|
||||
```
|
||||
|
||||
### Syntax:
|
||||
|
||||
```
|
||||
vim [FILE_PATH/FILE_NAME]
|
||||
```
|
||||
|
||||
### Examples:
|
||||
|
||||
1. To open the file named "demo.txt" from your current directory:
|
||||
|
||||
```
|
||||
vim demo.txt
|
||||
```
|
||||
|
||||
2. To open the file in a specific directory:
|
||||
|
||||
```
|
||||
vim {File_Path/filename}
|
||||
```
|
||||
|
||||
3. To open the file starting on a specific line in the file:
|
||||
|
||||
```
|
||||
vim {File_Path/filename} +LINE_NUMBER
|
||||
```
|
||||
### Modes in vim editor:
|
||||
There are some arguments as to how many modes that vim has, but the modes you're most likely to use are ```command mode``` and ```insert mode```. These [modes](https://www.freecodecamp.org/news/vim-editor-modes-explained/) will allow you to do just about anything you need, including creating your document, saving your document, and doing advanced editing, including taking advantage of search and replace functions.
|
||||
|
||||
### Workflow of `vim` editor:
|
||||
1. Open a new or existing file with ```vim filename```.
|
||||
2. Type ```i``` to switch into insert mode so that you can start editing the file.
|
||||
3. Enter or modify the text of your file.
|
||||
4. When you're done, press the ```Esc``` key to exit insert mode and back to command mode.
|
||||
5. Type :w or :wq to save the file or save and exit from the file respectively.
|
||||
|
||||
### Interactive training
|
||||
|
||||
In this interactive tutorial, you will learn the different ways to use the `vim` command:
|
||||
|
||||
[The Open vim Tutorial](https://www.openvim.com/)
|
||||
|
||||
### Additional Flags and their Functionalities:
|
||||
|
||||
|**Flags/Options** |<center>**Description**</center> |
|
||||
|:---|:---|
|
||||
|`-e`|Start in Ex mode (see [Ex-mode](http://vimdoc.sourceforge.net/htmldoc/intro.html#Ex-mode))|
|
||||
|`-R`|Start in read-only mode|
|
||||
|`-R`|Start in read-only mode|
|
||||
|`-g`|Start the [GUI](http://vimdoc.sourceforge.net/htmldoc/gui.html#GUI)|
|
||||
|`-eg`|Start the GUI in Ex mode|
|
||||
|`-Z`|Like "vim", but in restricted mode|
|
||||
|`-d`|Start in diff mode [diff-mode](http://vimdoc.sourceforge.net/htmldoc/diff.html#diff-mode)|
|
||||
|`-h`|Give usage (help) message and exit|
|
||||
|`+NUMBER`|Open a file and place the cursor on the line number specified by NUMBER|
|
||||
|
||||
### Read more about vim:
|
||||
|
||||
vim can not be learned in a single day, use in day-to-day tasks to get hands-on in vim editor.
|
||||
|
||||
To learn more about ```vim``` follow the given article:
|
||||
|
||||
[Article By Daniel Miessler](https://danielmiessler.com/study/vim/)
|
||||
|
||||
90
landing/docs/Commands/files/xargs.md
Normal file
90
landing/docs/Commands/files/xargs.md
Normal file
@@ -0,0 +1,90 @@
|
||||
# The `xargs` command
|
||||
|
||||
`xargs` is used to build and execute command lines from standard input
|
||||
|
||||
Some commands like grep can accept input as parameters, but some commands accepts arguments, this is place where xargs came into picture.
|
||||
### Syntax:
|
||||
|
||||
```
|
||||
xargs [options] [command [initial-arguments]]
|
||||
```
|
||||
|
||||
### Options:
|
||||
|
||||
```
|
||||
-0, --null
|
||||
```
|
||||
|
||||
Input items are terminated by a null character instead of by whitespace, and the quotes and backslash are not special (every character is taken literal‐ly). Disables the end of file string, which is treated like any other argument. Useful when input items might contain white space, quote marks, or back‐slashes.
|
||||
|
||||
|
||||
```
|
||||
-a file, --arg-file=file
|
||||
```
|
||||
|
||||
Read items from file instead of standard input. If you use this option, stdin remains unchanged when commands are run. Otherwise, stdin is redirected
|
||||
from /dev/null.
|
||||
|
||||
|
||||
```
|
||||
-o, --open-tty
|
||||
```
|
||||
|
||||
Reopen stdin as /dev/tty in the child process before executing the command. This is useful if you want xargs to run an interactive application.
|
||||
|
||||
|
||||
```
|
||||
--delimiter=delim, -d delim
|
||||
```
|
||||
|
||||
Input items are terminated by the specified character. The specified delimiter may be a single character, a C-style character escape such as \n, or an
|
||||
octal or hexadecimal escape code. Octal and hexadecimal escape codes are understood as for the printf command. Multibyte characters are not supported.
|
||||
When processing the input, quotes and backslash are not special; every character in the input is taken literally. The -d option disables any end-of-file
|
||||
string, which is treated like any other argument. You can use this option when the input consists of simply newline-separated items, although it is al‐
|
||||
most always better to design your program to use --null where this is possible.
|
||||
|
||||
```
|
||||
-p, --interactive
|
||||
```
|
||||
|
||||
Prompt the user about whether to run each command line and read a line from the terminal. Only run the command line if the response starts with `y' or
|
||||
`Y'. Implies -t.
|
||||
|
||||
|
||||
### Examples:
|
||||
|
||||
|
||||
```
|
||||
find /tmp -name core -type f -print | xargs /bin/rm -f
|
||||
```
|
||||
Find files named core in or below the directory /tmp and delete them. Note that this will work incorrectly if there are any filenames containing newlines or
|
||||
spaces.
|
||||
|
||||
|
||||
```
|
||||
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
|
||||
```
|
||||
Find files named core in or below the directory /tmp and delete them, processing filenames in such a way that file or directory names containing spaces or new‐
|
||||
lines are correctly handled.
|
||||
|
||||
|
||||
```
|
||||
find /tmp -depth -name core -type f -delete
|
||||
```
|
||||
|
||||
Find files named core in or below the directory /tmp and delete them, but more efficiently than in the previous example (because we avoid the need to use fork(2)
|
||||
and exec(2) to launch rm and we don't need the extra xargs process).
|
||||
|
||||
|
||||
```
|
||||
cut -d: -f1 < /etc/passwd | sort | xargs echo
|
||||
```
|
||||
|
||||
Generates a compact listing of all the users on the system.
|
||||
|
||||
|
||||
### Help Command
|
||||
Run below command to view the complete guide to `xargs` command.
|
||||
```
|
||||
man xargs
|
||||
```
|
||||
Reference in New Issue
Block a user