#!/bin/bash cat $1 |tr '\n' ' ' > kadai1.txt #引数に指定されたファイルの改行を、スペースに置き換えたファイルkadai1.txtを作る。 case $1 in kadai1-1_data.txt) #実行時引数がkadai1-1_data.txtの場合 ;; #kadai1-1_data.txtの場合を終了。 kadai1-2_data.txt) #kadai1-2_data.txtの場合 ;; #kadai1-2_data.txtの場合を終了。 kadai1-3_data.txt) #kadai1-3_data.txtの場合 ;; #kadai1-3_data.txtの場合を終了。 *) #実行時引数が指定されたファイル以外の場合 echo Error! echo このファイルは指定されていません。 #実行時引数が指定されたファイル以外の時、エラーを表示する。 exit #シェルスクリプトを終了。 ;; esac #場合分けを終了 echo ' ' >> kadai1.txt #kadai1.txtの最後ににスペースを追記することで改行を加え、2単語ひとまとまりで表示する。 cat ./kadai1.txt | tr '[a-z]' '[b-za-b]'| tr '[A-Z]' '[B-ZA-B]' cat ./kadai1.txt | tr '[a-z]' '[c-za-c]'| tr '[A-Z]' '[C-ZA-C]' cat ./kadai1.txt | tr '[a-z]' '[d-za-d]'| tr '[A-Z]' '[D-ZA-D]' cat ./kadai1.txt | tr '[a-z]' '[e-za-e]'| tr '[A-Z]' '[E-ZA-E]' cat ./kadai1.txt | tr '[a-z]' '[f-za-f]'| tr '[A-Z]' '[F-ZA-F]' cat ./kadai1.txt | tr '[a-z]' '[g-za-g]'| tr '[A-Z]' '[G-ZA-G]' cat ./kadai1.txt | tr '[a-z]' '[h-za-h]'| tr '[A-Z]' '[H-ZA-H]' cat ./kadai1.txt | tr '[a-z]' '[i-za-i]'| tr '[A-Z]' '[I-ZA-I]' cat ./kadai1.txt | tr '[a-z]' '[j-za-j]'| tr '[A-Z]' '[J-ZA-J]' cat ./kadai1.txt | tr '[a-z]' '[k-za-k]'| tr '[A-Z]' '[K-ZA-K]' cat ./kadai1.txt | tr '[a-z]' '[l-za-l]'| tr '[A-Z]' '[L-ZA-L]' cat ./kadai1.txt | tr '[a-z]' '[m-za-m]'| tr '[A-Z]' '[M-ZA-M]' cat ./kadai1.txt | tr '[a-z]' '[n-za-n]'| tr '[A-Z]' '[N-ZA-N]' cat ./kadai1.txt | tr '[a-z]' '[o-za-o]'| tr '[A-Z]' '[O-ZA-O]' cat ./kadai1.txt | tr '[a-z]' '[p-za-p]'| tr '[A-Z]' '[P-ZA-P]' cat ./kadai1.txt | tr '[a-z]' '[q-za-q]'| tr '[A-Z]' '[Q-ZA-Q]' cat ./kadai1.txt | tr '[a-z]' '[r-za-r]'| tr '[A-Z]' '[R-ZA-R]' cat ./kadai1.txt | tr '[a-z]' '[s-za-s]'| tr '[A-Z]' '[S-ZA-S]' cat ./kadai1.txt | tr '[a-z]' '[t-za-t]'| tr '[A-Z]' '[T-ZA-T]' cat ./kadai1.txt | tr '[a-z]' '[u-za-u]'| tr '[A-Z]' '[U-ZA-U]' cat ./kadai1.txt | tr '[a-z]' '[v-za-v]'| tr '[A-Z]' '[V-ZA-V]' cat ./kadai1.txt | tr '[a-z]' '[w-za-w]'| tr '[A-Z]' '[W-ZA-W]' cat ./kadai1.txt | tr '[a-z]' '[x-za-x]'| tr '[A-Z]' '[X-ZA-X]' cat ./kadai1.txt | tr '[a-z]' '[y-za-y]'| tr '[A-Z]' '[Y-ZA-Y]' cat ./kadai1.txt | tr '[a-z]' '[z-za-z]'| tr '[A-Z]' '[Z-ZA-Z]' #作成されたkadai1.txtの、大文字と小文字をそれぞれ一文字ずつずらす命令を実行する。 rm kadai1.txt #最後に一時的に作った改行の無いファイルを削除しておく。