Solved

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

Posted on 2014-09-04
3
238 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:Christopher Schene
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 38

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:Christopher Schene
ID: 40304827
Works, Thank you.
0
 
LVL 38

Expert Comment

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

Featured Post

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

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

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

717 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