The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to insert a line number on every line mopimp UNIX for Dummies Questions & Answers 3 03-25-2006 01:35 PM
Insert a line as the first line into a very huge file shriek UNIX for Advanced & Expert Users 3 03-09-2005 01:22 AM
2 Simple Questions champion UNIX for Dummies Questions & Answers 1 07-24-2002 08:45 AM
Simple questions champion UNIX for Dummies Questions & Answers 3 07-12-2002 03:42 AM
Simple grep questions nitin UNIX for Dummies Questions & Answers 2 10-15-2001 01:52 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-01-2007
peterl peterl is offline
Registered User
  
 

Join Date: Nov 2007
Location: Sydney, Australia
Posts: 5
Simple ed questions - insert line with dot

Hi
I've got a trivial question on using ed (yes, I know, other editors are better!)
How do I insert a line that is just a single dot? (That is, how do I insert a line that starts with a dot and then new line)
Thanks
Peter
  #2 (permalink)  
Old 11-02-2007
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 712
Hi.

What have you tried? ... cheers, drl
  #3 (permalink)  
Old 11-04-2007
peterl peterl is offline
Registered User
  
 

Join Date: Nov 2007
Location: Sydney, Australia
Posts: 5
What I've tried

Here's my entries:

$ ed
a
. enter a line of just a dot
But it doesn't enter a line with a dot, it leaves
insert mode
w file.txt
0 There's nothing in the buffer
q
$
  #4 (permalink)  
Old 11-04-2007
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 712
Hi.

Here's one way:

Code:
#!/usr/bin/env sh

# @(#) s1       Demonstrate one way to get a ".", dot into a file with ed.

set -o nounset
echo

debug=":"
debug="echo"

## Use local command version for the commands in this demonstration.

echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version bash ed

echo

# Create a file.
cat >data1 <<'EOF'
Hi.
Goodbye.
EOF

echo " Input file:"
cat data1

echo
echo " Conversation with ed:"
ed data1 <<'EOF'
1
a
.x
.
s/x//
w
q
EOF

echo
echo " Results from ed"
cat data1

exit 0

Producing:

Code:
% ./s1

(Versions displayed with local utility "version")
GNU bash 2.05b.0
GNU ed version 0.2

 Input file:
Hi.
Goodbye.

 Conversation with ed:
13
Hi.
15

 Results from ed
Hi.
.
Goodbye.

cheers, drl
  #5 (permalink)  
Old 11-04-2007
peterl peterl is offline
Registered User
  
 

Join Date: Nov 2007
Location: Sydney, Australia
Posts: 5
THANKS: Solved

Thanks. So I see one way to do it would be to enter a line of:
.x
and then substitute the x for nothing, leaving just the dot.
Thanks for your help
Peter
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0