Solved

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

Posted on 2014-09-04
3
222 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, EE MVE 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, EE MVE
ID: 40304832
You're welcome :)
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

825 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