not from freebsd to linux

24 May 2005, 8:36 am

more of those unix things i can never remember and always have to look up:

regexps

swap x=y; for y=x;
^(\t ]+)(.+)=(.+);$
\1\3=\2;

vi stuff

search and replace:
range/searchtext/replacetext/specifier e.g.,
%s/start/end/g
to get rid of extra ctrl-m’s from an improper transfer:
:%s/Ctrl-vCtrl-m//g

note: this is general unix-y stuff. another post has linux-specific stuff. i know, i know, it’s all in the man pages. you know what? nothing makes me feel more idiotic than canonical unix documentation.

2 comments on “not from freebsd to linux”

  1. Ezra

    how did i miss this post the first time around?

    First off, you should look at the command “tr”. It usually makes swaps a lot easier. Don’t know if it would help you from within vi or some other text editor, but there is a handy perl tr operator, if you ever use perl.

    Second, most unices have a command called “dos2unix” which will strip the ctrl-Ms out for you.

    I am an emacs user, but I have to say, vi’s regexps kick ass; emacs totally misses the boat by giving some bogus prompted-search-and-replace features intstead. Being able to confine regexps to specific ranges is great, too.

  2. summervillain

    how did i miss this post the first time around?

    Because the Original Information Architecture From Hell concealed it effectively.

    First off, you should look at the command “tr”. It usually makes swaps a lot easier. Don’t know if it would help you from within vi or some other text editor, but there is a handy perl tr operator, if you ever use perl.

    I’m trying to remember specifically what I was doing, and I think that I was running that regexp either on perl or javascript files. I do underuse tr.

    Second, most unices have a command called “dos2unix” which will strip the ctrl-Ms out for you.

    Neither my FreeBSD nor Linux RedHat installs included it by default — but I think I was mostly trying to give myself a way to remember to hit ctrl-v to enter control characters.

    I am an emacs user, but I have to say, vi’s regexps kick ass; emacs totally misses the boat by giving some bogus prompted-search-and-replace features intstead. Being able to confine regexps to specific ranges is great, too.

    I (obviously) never attained vi master status. I know there’s a way to have 26 different cut and paste buffers, but I never remember how to invoke it. I’m pretty comfortable as a journeyman with vi and use it for all my server-side editing. At heart, however, I am a dyed-in-the-wool Edit+ man.

Comment

Comments are subject to moderation. Unless you have been whitelisted, your comment will not appear on the site until it is approved. Links are allowed for whitelisted commenters; images are not permitted.