printf - Frustrated with simple awk command -
printf - Frustrated with simple awk command -
i trying list out contents of field 1 using function:
help(){ if [[ $# -eq 0 ]] ; echo '######################################' echo '' echo 'argument run run name must given: ./report.sh name' echo 'report names are:' allnames=$(cut -d '|' -f 1 $configfile | awk '{printf $0"\n"}') echo $allnames echo '######################################' exit 0 fi } the output :
$ bin/report.sh ###################################### argument run run name must given: ./report.sh name study names are: itema itemb ###################################### whereas want:
$ bin/report.sh ###################################### argument run run name must given: ./report.sh name study names are: itema itemb ###################################### if run cutting command get:
[david@kallibu]$ cutting -d '|' -f 1 conf/report.conf itema itemb whatdo need alter newline ?
your code be,
help(){ if [[ $# -eq 0 ]] ; echo '######################################' echo '' echo 'argument run run name must given: ./report.sh name' echo 'report names are:' allnames=$(awk -f'|' '{print $1}' $configfile) echo "$allnames" echo '######################################' exit 0 fi } you seek awk -f'|' '{print $1}' $configfile command value of first column | delimiter.
you need set allnames within double quotes. only, allnames variable got expanded.
awk printf newline
Comments
Post a Comment