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]

 



On 02Nov2009 11:27, Frantisek Hanzlik <franta@xxxxxxxxxxx> wrote:
| steve wrote:
| >On 11/02/2009 12:58 AM, Frantisek Hanzlik wrote:
| >>Hello all,
| >>[...snip...]
| >>Just something as "+/{pattern}" option in vim editor does.
| >>
| >>I want offer to (unexperienced) users edit (in shell script) some
| >>configuration files, and this should be done with some simple editor
| >>(no Emacs or vi). I think e.g. joe or mcedit is simple enough for
| >>these users, but joe nor mcedit cann't? probably? solve this demand
| >>(joe's command line option for jump to given line number (+nnn) isn't
| >>too much useable for this).
| >
| >This is a fairly common requirement when distributing applications which
| >may need config file changes, to inexperienced uses. My approach is
| >generally to provide a command rather have the users open an editor, eg:
| >
| >$ sed -i -e "s/foo = LOOK_FOR/foo = REPLACEMENT/" foo.conf
| >
| >of course you could precede that with something like ...
|
| I agree that variant with sed is in many respects more foolproof than
| direct editing, but in my case this isn't practical, as users need to
| see (and occasionally change) surrounding text too. Thus, classical
| editor is needed...

Ok, you'll have to to this on a per-editor basis, alas.

If joe has a +nnn option, try:

  # or egrep, depend what flavour regexp you're offering
  n=`grep -n "$pattern" <"$file" | sed 's/:.*//'`
  joe "+$n" "$file"

You'll need to work out variations for other editors, alas.
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

Forty years from now nursing homes will be filled with demented hackers,
studying their blank laptop screens nicely placed on knitted quilts to keep
their knees warm.       - K. Mitchum

-- 
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