fstabファイルの行を一致させる方法

fstabファイルの行を一致させる方法

/etc/fstabファイルに次の行があります

/dev/mapper/vg_D /data/container xfs     defaults        0 0

しかし、行を次のように一致させようとすると

LINE=/data/container

grep -qxF "$LINE" /etc/fstab || echo "line not in file !!!"
line not in line !!!

grep -qxFラインが合わないと思います。 /data/container

私たちはどこで間違っていますか?そして行を一致させる方法は何ですか?

ベストアンサー1

このパラメータを使用しないでください-x。行全体を一致させようとします。

       -x, --line-regexp
              Select only those matches that exactly match the whole  line.   For  a  regular  expression
              pattern, this is like parenthesizing the pattern and then surrounding it with ^ and $.

/data/containerしたがって、他の内容が含まれていない行のみが一致します。

おすすめ記事