私は次のコマンドを試しました
cut -c-11 ifshell.sh
cat ifshell.sh | cut -c-11 ifshell.sh
cat ifshell.sh | awk '{print $1} | cut -c-11 ifshell.sh
しかし、毎回.shファイルの内容全体を取得するたびに。このコマンドは.txtファイルで完全に機能します。主な目的は、「#!/ bin / bash」スクリプトの最初の11文字を抽出して、ファイルが実際にbash binスクリプトであることを確認することです。
ベストアンサー1
標準 -file
コマンドを使用することもできます。
[PRD][]user@localhost:~ 17:21:30
$ head -n 1 setproxymkt.sh
#!/bin/bash
[PRD][]user@localhost:~ 17:21:38
$ file setproxymkt.sh
setproxymkt.sh: Bourne-Again shell script, ASCII text executable