여러 명령을 for 루프로 변환

여러 명령을 for 루프로 변환

터미널에 명령을 여러 번 다시 입력하는 것은 성가실 수 있습니다.

기본적으로 그림의 예처럼 ogg_2x2 또는 ogg_1x1에 대해서만 이 명령을 실행할 필요는 없지만 모든 i에 대해 이 명령을 실행해야 합니다.데이터 세트(위 셀의 출력)

내가 생각해낸 것은 이것이지만, i와 $를 어떻게 사용하는지 모르기 때문에 엉망으로 만들었다고 확신합니다.

datasets=("input" "the" "elements" "of" "datasets" "from" "the" "notebook")
for i in "${datasets[@]}"; do
  ls *$i*mpin>$i.txt
  multipht list=$i.txt x=2 y=3 mag=4 err=5 jd=1 auto outfile=multipht_$i.out
  solvepht infile=multipht_$i.out outfile=$i.out varstar=0
done

데이터 세트의 모든 i에 대해 실행해야 하는 명령

답변1

다음을 시도하십시오

for i in "input" "the" "elements" "of" "datasets" "from" "the" "notebook"
do
  ls *${i}*mpin>${i}.txt
  multipht list=${i}.txt x=2 y=3 mag=4 err=5 jd=1 auto outfile=multipht_${i}.out
  solvepht infile=multipht_${i}.out outfile=${i}.out varstar=0
done

관련 정보