Linuxでは、のような簡単なコマンドライン条件を実行できます。2つのLinux条件を組み合わせることは可能ですか?
echo 'The short brown fox' | grep -q 'fox' && echo 'Found' || echo 'Not Found'
>> Found
それとも
test -e test.txt && echo 'File Exists' || echo 'File Not Found'
>> File exists
それが一つに二つの条件を組み合わせることが可能ですか?だからもし狐が見つかったら、ファイルが存在するかどうかを調べ、それに応じて条件を実行します。
私は次のことを試してみましたし、彼らが動作するように表示されません。
echo 'The short brown fox' | grep -q 'fox' && (test -e test.txt && echo 'File Exists' || echo 'File Not Found') || echo 'Fox Not Found'
echo 'The short brown fox' | grep -q 'fox' && `test -e test.txt && echo 'File Exists' || echo 'File Not Found'` || echo 'Fox Not Found'
私は、単一の行に場所を取るためにコマンドを必要としています。
これはエラーのようです:{:コマンドが見つかりません。 ファイルが見つかりません }:コマンドが見つかりません。 が見つかりません – difurious
あなたはどのシェルを使用していますか?これは 'bash'の私にとってうまくいきました – anubhava
私は-cshを使用しています – difurious