Search Results

Search: Posts Made By: Dave724001
11,629
Posted By Dave724001
Thank You!
Thank You!
11,629
Posted By Dave724001
grep error
Can anyone tell me what this error means?:

Usage: grep -hblcnsviw pattern file . . .

Thanks in advance!
3,056
Posted By Dave724001
Solved it. This will work if anyone else has...
Solved it.

This will work if anyone else has the same problem:

sed -n -e H -e '${' -e g -e 's/--#\n/newline \
/2' -e p -e \} file > newfile
3,056
Posted By Dave724001
Ok, Ive found out what I need to do, I need to...
Ok,
Ive found out what I need to do, I need to expand the pattern space to include the entire file (not just one line), then search for the nth occurence of '--#'.

Does anyone know how to do...
3,056
Posted By Dave724001
Oh I see, it works if I change the number to 9...
Oh I see, it works if I change the number to 9 (The line number of the second '--#'.

But I have many files and the 2nd occurnce of '--#' occurs on different lines in each file.

Is there anyway...
3,056
Posted By Dave724001
Thank you, that works on the first occurence if i...
Thank you, that works on the first occurence if i change the 2 at the start to a 1, but it doesnt work on the 2nd occurence if it is left as a 2!

Im not sure why!
3,056
Posted By Dave724001
Thanks that worked great! Is there any...
Thanks that worked great!

Is there any method of apply this to only the second line containing only '--#' and leaving the first line the same?

Thanks for your help!
3,056
Posted By Dave724001
Simple sed command
Hi,

I have the following file:

--#
--#line1
--#line2
--#line3
--#
--#line4
--#line5

and I want to use something like:

sed 's/--#/newline/g' file > newfile

to substitute the lines...
1,367
Posted By Dave724001
Sorry, I just wasnt sure if it was a beginners...
Sorry, I just wasnt sure if it was a beginners problem or an advanced problem!
Wont do it in the future!
1,367
Posted By Dave724001
sed command
I have a file like this:

--#
--#line1
--#line2
--#line3
--#line4
--#line5

--#
line6
line7
etc...

I want to insert a line before the second occurence of '--#' on its own.
eg I want...
1,319
Posted By Dave724001
sed command
I have a file which looks something like this:

--#
--#line1
--#line2
--#line3
--#line4
--#line5
--#line6

--#
line7
line8
line9
.........and so on


Id like to insert a line (2...
5,866
Posted By Dave724001
Its ok, I sorted it in the end! For anyone...
Its ok, I sorted it in the end!

For anyone else with the same problem, you dont need to change the first 2 delimiters, only the ones after the s! The following code works!

code:
sed...
5,866
Posted By Dave724001
Thats great! How would it be used if i wanted...
Thats great!
How would it be used if i wanted the first line somewhere in the middle of the rest of the line eg:

input:
line1
line2
line3

output:
line1
create|vt|line1...
5,866
Posted By Dave724001
Ok im stuck on the same command again! I want...
Ok im stuck on the same command again!
I want to put a filename after each of the lines, but the filename obviously contains '/' so I need to use a different delimiter, but when I change:

sed...
5,866
Posted By Dave724001
Thank you for that, it works perfectly! Uve...
Thank you for that, it works perfectly!
Uve saved me sooo much time!
Cheers!
5,866
Posted By Dave724001
Thanks for the reply, but I cant get that to...
Thanks for the reply, but I cant get that to work!
I was looking for a method which i dont need to type each line out because I need to run it on a file with 800 lines and I want it to do the same...
10,957
Posted By Dave724001
Thanks for the reply, but i tried it and it said:...
Thanks for the reply, but i tried it and it said:
sed: illegal option -- r

so I removed the -r and it said:
sed: command garbled: s/^(.*)$/\1new\n\1newline\n/

I dont understand why!
5,866
Posted By Dave724001
Sorry if im being stupid, but what would the code...
Sorry if im being stupid, but what would the code be if you wanted to add a third (or more) line to each line of original code? (each new line may contain the original line)

Thanks,
Dave
5,866
Posted By Dave724001
The first one worked, thank you for all your help!
The first one worked, thank you for all your help!
5,866
Posted By Dave724001
Yeah it definately is! I copied your code...
Yeah it definately is!
I copied your code exactly.
Ive been looking around and there are a few people with the same problem, apparently \n doesnt work on some versions of UNIX.
Do you know of any...
5,866
Posted By Dave724001
Yeah thats exactly what I want! But for some...
Yeah thats exactly what I want!
But for some reason, when I run it, i get:

file:
line1
line2
line3

cat file|sed 's/\(.*\)/\nextra\1/'>newfile

cat newfile:
nextraline1
nextraline2...
5,866
Posted By Dave724001
Thanks, that works for the first line, but i want...
Thanks, that works for the first line, but i want to create a second line with the first line in it. And the following code doesnt work.

sed -e 's/\(.*\)/\1\nextra\1/' -e '/\(.*\)/ a\\...
10,957
Posted By Dave724001
combining sed commands
I would like to change the lines:
originalline1
originalline2

to:
originalline1new
originalline1newline

originalline2new
originalline2newline

To do this, id like to combine the...
5,866
Posted By Dave724001
difficult sed command
Im trying to replace every line

line1
line2
line3

with:

line1
extraline1

line2
extraline2

line3
extraline3


with about 10 extra lines
I am able to add axtra lines with:
Showing results 1 to 24 of 24

 
All times are GMT -4. The time now is 07:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy