bash(というよりLinuxコマンド)強化週間。
https://cmdchallenge.com/
1
Your first challenge is to print “hello world” on the terminal in a single command.
printf 'hello world'
2
Print the current working directory.
pwd
3
List names of all the files in the current directory, one file per line.
ls | grep ''
lsを行った時点では1行につき1ファイル表示にならないが、grepに渡した後は1行につき1ファイル表示になる。
4
There is a file named access.log in the current directory. Print the contents.
cat access.log
5
Print the last 5 lines of “access.log”.
tac access.log | head -n 5 | tac
tac(catの逆)を2回使って戻している。
6
Create an empty file named take-the-command-challenge in the current working directory.
touch take-the-command-challenge
7
Create a directory named tmp/files in the current working directory
mkdir -p tmp/files
pはparents。
8
Copy the file named take-the-command-challenge to the directory tmp/files
cp take-the-command-challenge tmp/files
9
Move the file named take-the-command-challenge to the directory tmp/files
mv take-the-command-challenge tmp/files
10
Create a symbolic link named take-the-command-challenge that points to the file tmp/files/take-the-command-challenge.
ln -s tmp/files/take-the-command-challenge take-the-command-challenge
11
Delete all of the files in this challenge directory including all subdirectories and their contents.
find . -delete
たった一つのオプションをつけるだけでfindは恐ろしいコマンドになる。