Find a pattern from a folder

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
deepakdeshp
Level 20
Level 20
Posts: 12454
Joined: Sun Aug 09, 2015 10:00 am

Find a pattern from a folder

Post by deepakdeshp »

Hello,
In a folder there are .xls files. From these files a case insensitive pattern shiv* has to be found.pattern may be Shivag or shiva for etc.
Command

Code: Select all

grep  -i "shiv*" *xls
didn't work. Will be thankful for any help.
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
User avatar
devara
Level 4
Level 4
Posts: 235
Joined: Tue May 28, 2024 10:08 pm
Location: 🇮🇩 Indonesia

Re: Find a pattern from a folder

Post by devara »

Hi
try this?

Code: Select all

ls *.xls | grep shiv
ls *.xls | grep Shiv
LMDE 6 with 6.6.13+bpo-amd64 | Lenovo ThinkPad T450 | Intel© Core™ i7-5600U CPU @ 2.60GHz × 2 | Intel™ HD Graphics 5500

Hai, I'm just using gnu/linux for my stuff
deepakdeshp
Level 20
Level 20
Posts: 12454
Joined: Sun Aug 09, 2015 10:00 am

Re: Find a pattern from a folder

Post by deepakdeshp »

devara wrote: Mon Jun 10, 2024 9:58 am Hi
try this?

Code: Select all

ls *.xls | grep shiv
ls *.xls | grep Shiv
Thanks but it doesn't work. 0 is the output after running the command
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
mikeflan
Level 17
Level 17
Posts: 7585
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: Find a pattern from a folder

Post by mikeflan »

grep -i "shiv*" *xls
Change that to:

Code: Select all

grep -i shiv *xls
or just

Code: Select all

grep -i shiv *
Edit:
xls is a binary file. grep will not work reliably on the contents of a binary file. Convert the files to CSV and grep those.

Please confirm that you are looking for shiv INSIDE these file, and not on the file names.
Post Reply

Return to “Software & Applications”