Re: Shell question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 12/28/2016 06:14 AM, Andy Blanchard wrote:
On 27 December 2016 at 22:49, JD <jd1008@xxxxxxxxx> wrote:
Reading lines from 2 files in such a way that each iteration
lets me read the next line from each file so that the items
read from each file are in sync as far as line number is concerned.
Is this "doable"?
Maybe a little out of the box, but far simpler than the other
solutions so far if it'll do what you need:

    egrep -Hn . <file1> <file2> | sort -t: -k2 | cut -d: -f3-

It'll work with any number of input files, wildcards, and you play
with the sort/cut parts to get more descriptive output if you want as
well, e.g:

    egrep -Hn . <file1> <file2> ... <filen> | sort -t: -k2 | cut -d: -f1,3-


Andy
Does not work :(
it outputs first all the lines in file 1, followed by all the lines in file2.
In my case the sort and the cut are not even needed.
Jon LaBadie's example worked like a charm

exec 5< .kshrc
exec 6< .profile

while read -u 5 one && read -u 6 two
do
echo $one
echo $two
done
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]
  Powered by Linux