Solved

need sed command/pattern  to change a range of lines in  a stream

Posted on 2014-09-04
3
214 Views
Last Modified: 2014-09-04
I want to change all but the last line in a file using the sed stream editor.

In vi I would express it this way

1,$-1s/$/,&/g

Which reads "from the first line to the last less 1, add a comma to the end of the line"

basically i am separating a bunch of lines to be fed into excel as a .csv file.
0
Comment
Question by:cschene
  • 2
3 Comments
 
LVL 37

Accepted Solution

by:
Gerwin Jansen earned 500 total points
ID: 40304678
Try this:

sed '$!s/$/,/' your.csv

or to perform the change in your.csv file:

sed -i '$!s/$/,/' your.csv
0
 

Author Comment

by:cschene
ID: 40304827
Works, Thank you.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40304832
You're welcome :)
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
linux crontab output 3 65
bash script question (chmod) 10 53
How to have a cron job run until a condition is met 12 54
Steps to follow for Maintenance of Servers 4 50
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now