Find the text in the file and delete the rest of the line.
Hi,
I have one requiremnet like this. I need to find some particular string (eg.IncludeDateTime = ) in a file. And wherever it finds the string the unix script has to delete the remaining text coming after the string (ie., 'IncludeDateTime = ' ) in the same line. I tried to write this script in unix using 'sed' command but no luck. I am giving some example as below.
Ex. The file contains..
Last update date $$IncludeDateTime = 04/18/2012 11:38:55
The output I am expecting is..
Last update date $$IncludeDateTime =
Can any one please help in this regard. Heartful Thanks to all in advance.
Thanks Sarbjit. That is working fine. Now what I want is ..
Initial file is like this..
After executing the command
The out put is like this..
Now The third step is what I want is ..
I tried using the following command..
The output I am getting is ..
But what I want is..
Can anyone please let me know how to write the script for this. Thanks for your help..
Suresh
---------- Post updated at 01:25 PM ---------- Previous update was at 01:21 PM ----------
And where the variable $STR1 contains the date value of '01/01/12 10:12:10'. Which was defined in the earlier part of the script.
Hi ,
i have a file with data as below.This is same file. But actual file contains to many rows.
i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ?
Field 004... (7 Replies)
Hi friends,
I have a file where I should search for a string and get the rest of the line but without the delimiter using awk.
for example I have the series of string in a file:
input_string.txt
bbb
ccc
aaa
and the mapping file looks like this.
mapping.txt
aaa|12
bbb|23
ccc|43... (11 Replies)
Need to remove rest of line after the equals sign on search pattern from the searchfile. Can anybody help. Couldn't find any similar example in the forum:
infile:
64_1535: Delm. = 86 var, aaga
64_1535: Fran. = 57 ex. ccc
64_1639: Feb. = 26 (link). def
64_1817: mar. = 3/4. drz ... (7 Replies)
i need to find ' - ' in a line , if i found i need to rest of the line including '-'
example
libmm-2.0
libytytsunos-5.6
output
libmm
libytytsunos (7 Replies)
Hi all,
Our application installation uses "sed" command to delete rest of line. It work perfect on Linux but fail on Solaris.
The OS versions are Solaris 9 and Linux Red Hat AS 3.
yourfile.txt
hello and world
cat and dog
hello world
in linux:
cat yourfile.txt | sed ‘s/\(\+\)... (3 Replies)
PATTERN=""
sed "/$PATTERN/d" $file
In the file data is stored as
:::
:::
I need to delete only the line containing the PATTERN
pls help to point out why the above code is not working (4 Replies)
Hi,
How do I go about deleting a line in a text file. I have used grep to find a particlular word, now how do I delete the line?
so far I got:
grep -i $keyword file.txt (6 Replies)
Hi, can anyone please answer my question in deleting the rest of the line. I have an example below of a file contaning:
Serial3/1.5 43.70.195.13 YES NVRAM down down
Serial3/3 225.94.155.69 YES NVRAM up down
Serial3/6 ... (3 Replies)
I have a file with which i must remove the last line of the file (the footer). I know how to copy and redirect with tail -1 etc, but how do i delete it permanentely (4 Replies)