Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-11-2010, 09:43 PM
|
#1
|
LQ Newbie
Registered: Feb 2010
Posts: 3
Rep:
|
understanding 1,p$ construction in ed
OK, I'm truly a a newbie. I'm in a Linux class at a community college with the worlds worst instructor and a worthless textbook.
The book starts using the following ed construction:
1,$p 'Print all the lines'
but it doesn't give a clue about what the parts of this construction means. I asked the instructor and he gave me an obviously wrong answer about it putting it in a registry. I know he's confused. This guy knows zero linux.
I understand that the p is for print. I take it from the book that the $ means end of a line.
I have no idea what the 1 means or how the syntax of this line works. Since I gather that ed is a line editor I think it should only print one line anyway, but the "explanation" clearly says "print ALL the lines."
Google is no help, since it doesn't recognize symbols such as , and $.
Can anyone help me?
Roger
|
|
|
02-11-2010, 09:58 PM
|
#2
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,434
|
well, I'm surprised you're using 'ed' that's a precursor to vi (precursor to vim).
anyway, it looks like the vi/vim cmd
:1,$p
You get the ':' when in cmd mode (you can use ed-like constructions); meaning is
1 - start from first line
, - range marker
$ - to last line
p - print line
therefore, print all lines from 1 to $ (ie last line = end of file)
HTH
http://www.vim.org/
|
|
|
02-11-2010, 10:04 PM
|
#3
|
LQ Newbie
Registered: Feb 2010
Posts: 3
Original Poster
Rep:
|
Thank you
Thank you Chris.
Actually we're not using ed, we're using sed to learn about regular expressions, but this "beginners" book starts the chapter by saying "Throughout this section we assume familiarity with a line-based editor such as ex or ed."
Of course, that's the first reference to any such thing, and it stopped me dead in my tracks right there.
Anyway - enough blowing off steam. Thanks for your help.
Roger
|
|
|
02-11-2010, 10:12 PM
|
#4
|
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187
|
1 is line 1, $ is the last line, so 1,$p means "for line = 1 .. last_line; print line"
Note that this is an ed construction, and ed is a very seldom used Linux editor. ed is a great editor if you are using a real tty to edit a file, where your input and output is printed on paper. Most system in use today use CRT display systems, where the screen can be re-displayed to reflect changes, and - on a simple CRT display (one without a Graphical User Interface, a "GUI") an editor like nano or vi is much more common.
About the only current use of ed-like commands is in old programs (like mail and sed) ported from 1980s UNIX systems, and used, almost exclusively, by system administrators.
Of course, almost all current Linux distributions are shiped wit a GUI, and include several full-screen WYSIWUG (What You See Is What You Get) editors. While learning ed might be of interest to a historian, I can't see much point in including it in a Linux class.
(And, just FYI, no Linux system of which I'm aware has anything like a "registry." Most system and application control files in a Linux system are in the /etc directory, and they are simple, easily read, text files.)
Last edited by PTrenholme; 02-12-2010 at 12:57 PM.
|
|
|
02-11-2010, 10:23 PM
|
#5
|
LQ Newbie
Registered: Feb 2010
Posts: 3
Original Poster
Rep:
|
Registry meant register
I'm pretty sure he meant register, as in the construction
^\(.\).*\1$
where the result is places in a "register"
He just can't talk. Kinda like his constant use of the word "apprehend" to mean append.
|
|
|
02-11-2010, 11:01 PM
|
#6
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,434
|
apprehend = append a policeman to a criminal
BTW agree with PTrenholme. The main editor to at least know the basics of is vi; its installed by default on just about any/all versions of *nix, inc Linux, *BSD, AIX, Solaris, HP-UX, Mac-OSX (I believe).
The minimal recovery shell ash includes a cut-down version of vi built-in.
Also, very low overhead for low bandwidth cxns.
|
|
|
All times are GMT -5. The time now is 11:39 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|