Welcome to the Linux Foundation Forum!

how to lookup a reference file column and fetch 3 rd column

Options

Can any one help me with the below scenario
i have a reference file has data below

file_id|file_name
1|file1.txt
2|file2.txt
3|file3.txt

i have a script which accepts input as file_id and fetch 2 nd column .

file_id=$1
header=$(awk -v a=$file_id -F '~' ¨$1==a {print $2}" /test/data/shared/dev/SrcFiles/datawarehouse/poc/file_ref_master.txt)

this is giving me blank value instead of file name .

output

vi file_lookup_poc.sh
$ sh -x file_lookup_poc.sh 1

  • file_id=1
    ++ awk -v a=$file_id -F '~' '$1==a {print $7}' /test/data/infa_shared/dev/poc/file_ref_master.txt

  • header=

  • echo

Comments

  • fedwards
    Options

    What is the proper handling for off-topic posts like this? It's clearly not related to kernel development. (This user has posted on other forums as well, such as community.unix.com.) Do I just flag it and let a moderator see it, or something else?

Categories

Upcoming Training