I want to import a textfile with getline into var t which has several lines. How do import all lines, since it only imports the last line:
while < ((getline t "textfile") > 0)
I want to import a textfile with getline into var t which has several lines. How do import all lines, since it only imports the last line:
while < ((getline t "textfile") > 0)
awk '{a=a$0}END{print a}' input.txt
Can't use your script this is why i need the getline function:
file1.txt
file1
file2
file4
impg_dir_list.csv
file; img; description
file1;c:\a\img1.jpg;c:\a\img1.txt
file2;c:\b\img2.jpg;c:\b\img2.txt
file3;c:\c\img3.jpg;c:\c\img3.txt
file4;c:\d\img4.jpg;c:\d\img4.txt
awk 'NR==FNR{z[$1]=$1;next} $1 in z {while < ((getline t $3) > 0); print $1 , $2 t}' file1.txt img_dir_lit.csv >output
What should be the desired output?
I want only the lines from file1.txt which are in impg_dir_list.csv to be printed and the description from the corresponding description-file ($3 of impg_dir_list.csv.). The despcription-file though is multiline.
output:
file1, image.jpg, description
Something like this?
awk -F; 'NR==FNR{a[$1];next}$1 in a' file1.txt impg_dir_list.csv > output
No, since this just reads the filename with its path but not the content of the multiline-textfile from:
c:\a\img1.txt -->content: multiline text shall also be printed
c:\b\img2.txt
c:\c\img3.txt
c:\d\img4.txt
Elaborate your question if this isn't what you want:
awk -F; '
NR==FNR{a[$1]; next}
$1 in a {
s=$1 , $2
while((getline line < $3) > 0 ) {
print s, line
}
}' file1.txt impg_dir_list.csv > output