This code will give the first part, but how can I remove it and get the whole string without the first part?
echo "first second third etc"|cut -d " " -f1
を参照してください。意味info cut
が説明されていf1
ます。
実際には、2 番目のフィールドの後にフィールドが必要です。-f
はフィールドで検索するようコマンドに指示し2-
、2 番目以降のフィールドを意味します。
echo "first second third etc" | cut -d " " -f2-
You can use substring removal for that. There isn't any need for external tools:
$ foo="a b c d"
$ echo "${foo#* }"
b c d
できるよ:
echo "first second third etc" | cut -d " " -f2-
>> second third etc
これを試してください:
echo "first second third etc" | cut -d " " -f2-
で説明されています
man cut | less +/N-
N- N 番目のバイト、文字、またはフィールドから行末まで
Bash tagがある限り、次のようにBash パラメータ展開を使用できます。
x="first second third etc"
echo ${x#* }
これを試して:
echo "first second third etc" | cut -d " " -f2-