Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
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…
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…
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.

730 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