Want to delete the record if I find a word (dd)in the fixed length(5-7).

Want to delete the record if I find a word (dd)in the length(5-7). Lets think that (5-7) length is FF2.
This is a fixed width file.
ex f1
ff1 ff2 ff3
sds dd fd
sd ss ew
dd dd se
o/p should be like

ff1 ff2 ff3
sd ss ew

Questions by bujji4you

Showing Answers 1 - 33 of 33 Answers

suvarna

  • Jul 27th, 2012
 

in vi mode

:/dd/d(dd is the pattern which u want to delete)

  Was this answer useful?  Yes

Gaurav

  • Oct 2nd, 2012
 

sed s/dd //g file

  Was this answer useful?  Yes

SaintHax

  • Oct 4th, 2012
 

sed /dd/d $file

  Was this answer useful?  Yes

Mohit

  • Nov 14th, 2014
 

Code
  1. awk {if(substr($0,5,2)!="dd" || substr($0,6,2)!="dd" ) print $0} filename  >> file_name

  2.  

  Was this answer useful?  Yes

Ishaan Guliani

  • Sep 27th, 2015
 

awk $2 != "dd" {print $0} ntmp.tt

  Was this answer useful?  Yes

sandip

  • Oct 4th, 2015
 

sed /dd/d test.sh

  Was this answer useful?  Yes

rahul

  • Jun 13th, 2016
 

for i in `cat z.txt`
do
j=`expr length $i`
if [[ ( "$j" == 5 || "$j" == 7 ) ]]
then
v=`echo $i|grep dd`
if [ "$v" != "" ]
then echo $v
sed -i "s/$v/lalat/g" z.txt
fi
fi
done

  Was this answer useful?  Yes

pankaj

  • Dec 12th, 2016
 

awk {if (substr($0,4,2) != "dd" && substr($0,5,2) != "dd" ) { print} } z.txt

  Was this answer useful?  Yes

Navi

  • Dec 28th, 2016
 

sed /dd/d file_name

  Was this answer useful?  Yes

shailesh chanderiya

  • Aug 26th, 2017
 

line_no=` sed -n /^...*dd/=;p temp | sed -n /^[0-9]/p |xargs|sed s/ /d;/g;s/$/d/`
sed -i "${line_no}" temp

  Was this answer useful?  Yes

pranav Rakesh

  • Sep 26th, 2017
 

sed /[dD]$/d file

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions