Re: How to set cursor in editor to pattern given on command line?

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

 



I wrote:
> How does
> nano +100 /etc/services
> look to you? (^X means ctrl-X)
pressed “Send”, and realised you wanted to open at a regexp, not a fixed
line.

That sounds like a job for shell scripting.

If the file isn’t massive, try something like:
nano +$(grep -n "message submission" /etc/services|head -n1| cut -d: -f1) /etc/services 

That’s
grep -n pattern $FILENAME
to find the pattern, prefixed with the line number. Pipe it through
head -n1
to get the first line with it on, and then through
cut -d: -f1
to get everything before the colon (which will be the line number you
want). Put all of that in `` or in $( ) , which will mean the shell will
interpret the contents of `` or $( ) and put the result (in this case
the line number) there instead.

That should work for any editor which understands the +line-no notation,
which I think is most of them.

Hope this helps,

James.

-- 
E-mail:     james@ | “The letters are Elvish, of an ancient mode, but the
aprilcottage.co.uk | language is that of Microsoft, which I will not utter
                   | here. But this in the Common Tongue is what is said: By
                   | this or any other name, You are well and truly...”

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux