Given some data like so:
"Something something","1234567890123456","12/34/5678","Other thing","123",""
I'm trying to get awk
to print the fields and then export them to the X
clipboard using xclip
with the following:
echo $data | sed 's/"//g' | awk -F',' '{for(i=1;i<NF;i++) {print $i; system("echo \"" $i "\" | xclip -i")}}'
which correctly gives the right output:
Something something
1234567890123456
12/34/5678
Other thing
123
but it seems to only copy the last field to the clipboard. I am using a clipboard manager (klipper
) so I would expect there to be all of the fields listed.
What am I missing?
xclip -i
once for each line of input. Isxclip -i
incremental or does each run replace the clipboard contents? Did you mean to us| xclip -i
on the output fromawk
?for loop
syntax is wrong(for i=1;i<NF;i++)
for(i=1;i<NF;i++)
not(for i=1;i<NF;i++)