1

I have some text file like this

access-2018-08-21.log.1-20180906
access-2018-08-22.log.1-20180906

I want to remove the -20180906 part wo the result would be

access-2018-08-21.log
access-2018-08-22.log

I tried rename -- "s/\-20180906//g" * but it didn't work.

What's the command line i need to achieve my goal?

The One
  • 4,862

1 Answers1

1

Try this..

if you are happy with the output, then just remove the echo word.

for i in access*; do echo mv $i ${i%.*}; done
Kamaraj
  • 4,365