Solved

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

Posted on 2014-09-04
3
209 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 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

21 Experts available now in Live!

Get 1:1 Help Now