10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Sed command to replace a line in a file using line number from the output of a pipe.
Is it possible to replace a whole line piped from someother command into a file at paritcular line...
here is some basic execution flow..
the line number is 412
lineNo=412
Now i have a line... (1 Reply)
Discussion started by: vivek d r
1 Replies
2. Shell Programming and Scripting
Hi guys, I am currently using this to save first 50 lines into top50.txt and delete them from list.txt ... it's 2 commands:
head -n 50 list.txt > top50.txt && sed -i "1,50 d" list.txt
I want to change that so it's 1 command - whereby sed removes the first 50 lines as above but that which is... (3 Replies)
Discussion started by: holyearth
3 Replies
3. Shell Programming and Scripting
I was using the following option to clean up the ^M characters in a file that was FTPed from Windows:
- dos2unix
- sed 's/^M//g'
The ^M characters are removed but the last line is also getting removed. Any idea why this is happening.
Satish (2 Replies)
Discussion started by: vskr72
2 Replies
4. Shell Programming and Scripting
If I have this:
perl -pne 's/img_onload.{8}//g'
How would I do to instead of replacing img_onload.{8} with "nothing", get "nothing" to be a deleted line? Kind of the opposite to \n. (2 Replies)
Discussion started by: KidCactus
2 Replies
5. Shell Programming and Scripting
So, I want to read line-by-line a text file with unknown number of files....
So:
a=1
b=1
while ; do
b=`sed -n '$ap' test`
a=`expr $a + 1`
$here do something with b etc
done
the problem is that sed does not seem to recognise the $a, even when trying
sed -n ' $a p'
So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies
6. Shell Programming and Scripting
Hi,
After looking on different forums, I'm still in trouble to parse a parameters line received in KSH.
$* is equal to "/AAA:111 /BBB:222 /CCC:333 /DDD:444"
I would like to parse it and be able to access anyone from his name in my KSH after.
like
echo myArray => display 111
... (1 Reply)
Discussion started by: RickTrader
1 Replies
7. Shell Programming and Scripting
I have a somewhat bizarre problem when trying to concatenate lines in a file.
Using cat file.txt | sed -e :a -e '/$/N;s/\n/ /;ta' the output in file.txt should go from
1
2
3to 1 2 3 instead I only get the last line or 3.
I find that if I open the file in gedit and hit delete in front of every... (7 Replies)
Discussion started by: pluto7777
7 Replies
8. UNIX for Dummies Questions & Answers
Hi,
I want to use the sed command to delete some lines in a file and I was wondering whether there is a possibility of knowing which lines are deleted, or at least which line numbers.
Thanks (4 Replies)
Discussion started by: vanagreg
4 Replies
9. Shell Programming and Scripting
For lists in sed, to say what to replace, is this correct:
I am hoping that this would recognise that either a "." is present, or that the substitution happens at the end of the line.
For files with extensions , my script works perfectly.
My problem is, files without extentions, i.e. . ... (1 Reply)
Discussion started by: busillis
1 Replies
10. UNIX for Dummies Questions & Answers
Hi all,
I've searched the web and this forum for this but not had any luck. I'm trying to use sed so when it finds a space it will insert a new line.
What i have is a file containing .e.g
1 2 4 7 9
and want it to look like
1
2
4
7
9
I've tried:
more test2 | sed 's/ /\\n/g'... (1 Reply)
Discussion started by: Cordially
1 Replies