Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
シェルスクリプト内で次のパターンを使用しようとしています。以下を使用したい:
grep ^"#" $fn | grep -v NM$ > $op
しかし、bashスクリプト内。問題は、通常bash、「#」の後のすべてをコメントと見なすことです。私が使用する場合
bash
grep ^"\#" $fn
意味が変わると思います。私は初心者です。
どんな助けでも大歓迎です。
複数の可能性があります。
grep '^#' $fn
また
grep "^#" $fn
grep ^\# $fn
ここに私が保存した小さな例がありますfoo.sh
foo.sh
echo "#" echo '#' # this is a comment echo '\#'
sh foo.shこれが出力されるものとして実行すると
sh foo.sh
# # \#