sed overwrite
hi lq,
i have this Code:
sed -p s/^$/0/g lq.txt thanks, |
sed -i (RTM)
|
huh:
Code:
sed -i (RTM) |
Hi,
-i only works if sed 4.X or better is used, prior to that it takes a bit more then just one parameter: sed -p s/^$/0/g lq.txt > /tmp/lq.txt mv /tmp/lq.txt . Hope this helps. |
sed: filter dupes
yeah that's the patch i used is my script. thanks guys,
amways, how do i use sed to leave the first of a pattern untouched. then print the line number where the same pattern exists... thanks, |
sed can do what you're asking for (it's turing-complete), but you might want to look into something else--awk springs to mind.
I'd probably do it in python: Code:
from sys import stdin |
perhaps grep does what your looking for?
> grep -n pattern filename this prints the line number and line that the matches pattern. if you only want the line number, you could pipe it to something that will filter out the line and leave the line number: > grep -n pattern filename | cut -d: -f1 the lines, with thier line number, are piped into cut, which sets the field delimiter to ':' (-d:) and cuts out all but the first field (-f1), then prints the result to the screen. |
i dont think aix has python:
/> which python which: 0652-141 There is no python in $path awk might work. what i want is if col5 is uniq then add col 11 to total. i would like to keep the non-uniq rows but change col 11 to 0 for the repeated col 5's. any help is appreciated... is there a way to tell awk what lines to operate on ? |
yes, you can tell awk to only work on certain lines. do a google for awk/gawk reference and look for 'addresses'
for example: > gawk '/pattern/ {print $2}' says to print the second field of all lines (or records) that contain 'pattern' > gawk 'NR > 5 {print $1}' prints records (lines) 6 and up. |
All times are GMT -5. The time now is 09:32 AM. |