10.3

saki14moro@DESKTOP-GI15UG8:~$ cat test.sh
echo "test"

ls

pwd

hako='konnitiha'
hensuu='ohayou'

echo “昼は${hako}。夜は${hensuu}”
saki14moro@DESKTOP-GI15UG8:~$ sh test.sh
test
test.sh  test2  test4.tx
/home/saki14moro
“昼はkonnitiha。夜はohayou”
saki14moro@DESKTOP-GI15UG8:~$ sh test.sh > test4.txt
saki14moro@DESKTOP-GI15UG8:~$ cat test4.txt
test
test.sh
test2
test4.tx
test4.txt
/home/saki14moro
“昼はkonnitiha。夜はohayou”
saki14moro@DESKTOP-GI15UG8:~$ sh test4.txt
test4.txt: 2: test.sh: not found
test4.txt: 3: test2: not found
test4.txt: 4: test4.tx: not found
test4.txt: 5: test4.txt: not found
test4.txt: 6: /home/saki14moro: Permission denied
test4.txt: 7: “昼はkonnitiha。夜はohayou”: not found
saki14moro@DESKTOP-GI15UG8:~$ test
saki14moro@DESKTOP-GI15UG8:~$
saki14moro@DESKTOP-GI15UG8:~$ test2
Command 'test2' not found, did you mean:
  command 'test' from deb coreutils (8.32-4.1ubuntu1)
  command 'testr' from deb python3-

 

grep

 

saki14moro@DESKTOP-GI15UG8:~$ grep 'ohayou' test4.txt
“昼はkonnitiha。夜はohayou”
saki14moro@DESKTOP-GI15UG8:~$ grep -v 'test' test4.txt
/home/saki14moro
“昼はkonnitiha。夜はohayou”
saki14moro@DESKTOP-GI15UG8:~$ grep -v 'test' test4.txt | head
/home/saki14moro
“昼はkonnitiha。夜はohayou”

saki14moro@DESKTOP-GI15UG8:~$ grep -v 'ohayou' test4.txt
test
test.sh
test2
test4.tx
test4.txt
/home/saki14moro

 

head 最初5行

grep 検索したい文字含むものを抽出する。

-v 検索したい対象を含まないものを抽出