Please see my linux bash script below. I can't achieve my target output with my current code. It keeps reading the whole column 4.
input_file.txt:
REV NUM |SVN PATH | FILE NAME |DOWNLOAD OPTIONS
1336 |svn/Repo/PROD | test2.txt |PROGRAM APPLICATION_SHORT_NAME="SQLGL" |
1334 |svn/Repo/PROD | test.txt |REQUEST_GROUP REQUEST_GROUP_NAME="Program Request Group" APPLICATION_SHORT_NAME="SQLGL" |
my code:
# /bin/bash
REV_NUM=($(awk -F "|" 'NR>1 {print $1}' input_file.txt))
COMPONENT=($(awk -F "|" 'NR>1 {print $3}' input_file.txt))
DL_OPS="$(awk -F "|" 'NR>1 {print $4}' input_file.txt)"
#LOOP
REV_NUM_COUNT=${#REV_NUM[*]}
for (( x=0 ; x<$REV_NUM_COUNT ; x++ ))
do
echo "${COMPONENT[x]} ${DL_OPS[x]}"
done
actual output:
Exporting Component from SVN . . .
test2.txt PROGRAM APPLICATION_SHORT_NAME="SQLGL"
REQUEST_GROUP REQUEST_GROUP_NAME="Program Request Group" APPLICATION_SHORT_NAME="SQLGL"
test.txt
target output:
Exporting Component from SVN . . .
test2.txt PROGRAM APPLICATION_SHORT_NAME="SQLGL"
test.txt REQUEST_GROUP REQUEST_GROUP_NAME="Program Request Group" APPLICATION_SHORT_NAME="SQLGL"
Thank you so much
Asked by user765641
(31 rep)
Aug 4, 2025, 02:53 AM
Last activity: Aug 4, 2025, 07:20 PM
Last activity: Aug 4, 2025, 07:20 PM