You're viewing a comment by priyoma basu and its responses.

priyoma basu Permalink
November 30, 2012, 11:10

Hello, please help me with this question -
Write a sed command that will go through a file and eliminate any .5 at the end of a record. If .5 is anywhere else in the record, leave it alone. Have the sed command only display those records which are modified. (sample input & output as follows)


Input:

1:2:3:4
1:3:5:7.5
1.5:2.5:3.5:7.5
1.5:2:3:4
1:2.5:3:4

Output:

1:3:5:7
1.5:2.5:3.5:7

Comment Responses

MALLAREDDY N Permalink
October 27, 2014, 06:08

cat q91.txt
1:2:3:4
1:3:5:7.5
1.5:2.5:3.5:7.5
1.5:2:3:4
1:2.5:3:4
sed -n 's/\.5$//gp' q91.txt
Output:
1:3:5:7
1.5:2.5:3.5:7

Description:

with -n don't print lines, and then with /p - print matched lines only

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "apple_95": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.