0

I have a File Pattern Like

Listing "/MySqlDB-Backup"... DONE

[F] 202818 MySql-DataBase-2020-09-26_111645.zip

[F] 211436 MySql-DataBase-2020-10-05_063303.zip

How can I extract Only the Name of the files Like

MySql-DataBase-2020-09-26_111645.zip

MySql-DataBase-2020-10-05_063303.zip

Any Grep/awk/sed command which can work?

I tried using grep -w "MySql-DataBase" The Output was :

MySql-Database
MySql-Database
MySql-Database

I want to use it in Bash

Inian
  • 80,270
  • 14
  • 142
  • 161
Am3Y
  • 75
  • 4
  • 1
    what commands have you already tried? – Slava Oct 05 '20 at 11:11
  • 1
    Before asking here, you need to do some research and make some attempts yourself first. If you get stuck on something _specific_ with your code along the way, come back, show us what you've tried, the expected result and what results you're getting. Please read [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) and [How do I ask a good question](https://stackoverflow.com/help/how-to-ask) – M. Eriksson Oct 05 '20 at 11:14
  • Is this question for CLI or PHP? – M. Eriksson Oct 05 '20 at 11:16
  • Could you confirm "[F] 202818 MySql-DataBase-2020-09-26_111645.ziz" on line number 2 is end with ".ziz" or ".zip", please edit post if needed. – stackoverflower Oct 05 '20 at 11:22
  • I tried using grep -w I tried to search but the result was only "MySql-DataBase" nothing else I need to use it in bash script I am sorry it was a typing mistake its .zip – Am3Y Oct 05 '20 at 11:26
  • 1
    Try with `grep -o "[^ ]*\.zip"` or `grep "\[F\]" file_name | awk '{print $3}'`. Good luck – stackoverflower Oct 05 '20 at 11:28
  • 1
    It worked with this command grep -o "[^ ]*\.zip" Thanks :) – Am3Y Oct 05 '20 at 11:31
  • Does this answer your question? [Can grep show only words that match search pattern?](https://stackoverflow.com/questions/1546711/can-grep-show-only-words-that-match-search-pattern) – thanasisp Oct 06 '20 at 19:05

0 Answers0