10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Use sed to print first n lines and last n lines of an output.
For example: n=10
Can it be done?
Thanks. (7 Replies)
Discussion started by: carloszhang
7 Replies
2. UNIX for Dummies Questions & Answers
I am getting the varible value from a grep command as:
var=$(grep "Group" File1.txt | sed 's/Group Name*//g;s/,//g;s/://g;s/-//g')
which leaves me the value of $var=xyz.
now i want to append $var value in the begining of all the lines present in the file. Can u please suggest?
Input file:
1... (10 Replies)
Discussion started by: rade777
10 Replies
3. Shell Programming and Scripting
Hi All
I'm trying to extract the line just above a regexp and all lines after this.
I'm currently doing this in two steps
sed -n -e "/^+---/{g;p;}" -e h oldfile.txt > modified.txt
sed -e "1,/^+---/d" -e "/^$/d" oldfile.txt >>modified.txt
Sample
sometext will be here
sometext will be... (3 Replies)
Discussion started by: Celvin VK
3 Replies
4. Shell Programming and Scripting
I am trying to extract a table of data (mysql query output) from a log file. I need to print everything below the header and not past the end of the table. I have spent many hours searching with little progress. I am matching the regexp +-\{99\} with no problem. I just can't figure out how to print... (5 Replies)
Discussion started by: godfreydanials
5 Replies
5. Solaris
Hi guys.
I need a sed command to print like 10 lines after a regular expression is found in the log.
Can anyone help me out.
Thanks
---------- Post updated at 10:52 AM ---------- Previous update was at 10:34 AM ----------
never mind.
I just did the search bewteen two expressions. (1 Reply)
Discussion started by: jamie_collins
1 Replies
6. Shell Programming and Scripting
Hello!
Im trying to read file contents. Then, print out every line that has "/bens/here" in the file that was read.
cat /my/file.now | sed '/bens/here/p'
I keep getting the error asking if I need to predeclare sed?
What does predeclaring sed mean?
Thanks!
Ben (2 Replies)
Discussion started by: bigben1220
2 Replies
7. Shell Programming and Scripting
HiCan someone show me how to print all lines from a file after a line matching a pattern using sed?Thanks (13 Replies)
Discussion started by: steadyonabix
13 Replies
8. Shell Programming and Scripting
Hello,
I'm trying to move the last word of matching pattern to the begining of next line. Appreciate if anyone post the script.
From the below line I'm getting the last word, Note: this word also appears in many places in my file
#return the last word of line that contains ListenPort
sed... (4 Replies)
Discussion started by: baskar
4 Replies
9. Shell Programming and Scripting
From the below file I want to grep only the lines except the comment sections. But grep -v "#" is eliminating the last line because it has one # in between.
Any idea how can I ignore only the lines which have # at the begining (I mean comment lines) ?
Thanks a lot to all in advance
C Saha (1 Reply)
Discussion started by: csaha
1 Replies
10. Shell Programming and Scripting
Is there a standard way to make a shell script read a file, or list, and skip each line that contains # at the begining, or ignores the content starting after a # in line?
I'm looking to mimic the way commenting in a shell script normally works. This way I can comment my text files and lists my... (4 Replies)
Discussion started by: sysera
4 Replies