I have list of file names file1,file2,file3
I want to pass these file names in the script and remove the special characters
I prepared sed command to remove the special characters
sed -i -e 's/^B/,/g' /home/data/nfiledata/
hdfs dfs -put -f /home/data/nfiledata/* user/sai/table1/nfiledata/
gzip /home/data/nfiledata/*
sed -i -e 's/^B/,/g' /home/data/marginfile/
hdfs dfs -put -f /home/data/marginfile/* user/sai/table2/marginfile/
gzip /home/data/marginfile/*
sed -i -e 's/^B/,/g' /home/data/calldata/
hdfs dfs -put -f /home/data/calldata/* user/sai/table3/calldata/
gzip /home/data/calldata/*
My question is instead of writing multiple times same command can i write in one command and loop the process for each file using Shell script
nfile = (nfiledata,margindata, calldata)
while IFS= read -r nfile
do
sed -i -e 's//,/g' /home/data/$nfile/
hdfs dfs -put -f /home/data/$nfile/* user/sai/table$/$nfile/
gzip /home/data/$nfile/*
done < "home/data/$nfile"