Search Data DD/MM/YYYY HH:MM:SS

Search "DD/MM/YYYY HH:MM:SS" in a file & this format needs to provide input value while executing & remove all the content whatever is before the input value in a file
Eg : #myscript.sh 31/10/2015 10:15:22

Showing Answers 1 - 3 of 3 Answers

Manish

  • Jan 13th, 2016
 

#!/user/bin/sh
read -p $D
read -p $m
read -p $Y
read -p $H
read -p $M
read -p $S
datestring=$D/$m/$Y $H:$M:$S
sed -p 1,/$datestring/d filename > newfilename
mv filename file_backup
mv newfilename filename

  Was this answer useful?  Yes

Yogesh

  • Aug 31st, 2017
 

ls -ls * | grep "19/01/1989"

  Was this answer useful?  Yes

Mahender Lal

  • Sep 2nd, 2017
 

To search "DD/MM/YYYY HH:MM:SS" in a file
grep -Eo [0-9]{2}/[0-9]{2}/[0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} 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