I am writing a bash script that accepts a manifest.txt
file. It should cycle through each row of that text file and call another script to pass the text string from the row of the text file after separating the string of text by the space delimiter.
I am stuck on figuring out how to split the text string; I tried to use cut -d' '
, but it has not worked for me.
Here's the example of the text file:
20200451310 B.315
30203131340 Pam 3781, no.1
20200461200 B.16
20200471180 B.116, B.198
20200471190 B.129
10107291410 B.102
30203141220 Pam 3870, no. 1
20200481160 B.525
Here's the bash script I have so far:
#!/bin/bash
IFS=$'\n' # make newlines the only separator
set -f # disable globbing
for i in $(cat < "${manifest.txt}"); do
echo " $i"
uid = ${i | cut -d' ' -f1}
string = ${i | cut -d' ' -f2-10}
echo "uid is ${uid}"
echo "string is ${string}"
/anotherscript.sh ${uid} ${string}
done
The result should be, for example:
/anotherscript.sh "30203141220" "Pam 3870, no. 1"