[Infrastructure] While command summary

1. Basic while statement

command


while true
> do
> echo "hello world"
> sleep 1
> done

Output result


//Implementation results
hello world  //Repeat endlessly
hello world

File search + content string search

command


$ find ./ -type f -name "sample.txt" | while read line;
> do
> $line
> grep sample $line
> done

Output result


./tmp/sample.txt
sample

File search + character string search (excludes some search targets)

command


$ find ./ -type f \! \( -name "exclusion" -o "test" \) | while read line;
> do
> echo $line
> grep sample $line
> done

Output result


./tmp/sample.txt
sample

Directory information retrieval

command


$ find / -type d | xargs ls -ld | awk '{print $3,$4,$6,$9}' | sort

Output result


root root January 14th/tmp/test

Vim frequent operation

First line head: 1G or gg
Last line beginning: G

Cursor line beginning:^
End of cursor line:$

1 word Next: w
One word before: b
End of word: e

Cancellation: u

1 line copy and paste: yyp
Multi-line copy and paste: 10yyp

Delete one line: dd
Delete multiple lines: 10dd

Replacement:%s/before/after/g

Recommended Posts

[Infrastructure] While command summary
Linux Command Summary
Docker command summary
[Linux] Basic command summary
Find, locate command summary
Image related command summary
[Learning memo] Django command summary
[Linux] User / group command summary
[Infrastructure] Linux command, shell script collection
Jupyter Notebook Magic Command Personal Summary
Summary of "nl command Advent Calendar 2020"
[Linux command summary] Command list [Must-see for beginners]
Linux operation for beginners Basic command summary