zgrep and grep same time

how to search both zip  files and regular files same time

zgrep  "ram" *

grep  "ram" *

i like to combine above two

just use pipe?how to get result count as well on both files or on each file separately

how to create zip file here to test it?
https://www.tutorialspoint.com/unix_terminal_online.php
please advise
LVL 7
gudii9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
zgrep already does this.

zgrep will search zipped or unzipped files.

So the answer is just use zgrep for searching both file types.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arnoldCommented:
You can use compress on your Linux platform, not sure why you are looking online to create a file where you have tools locally
man -k zip
0
gudii9Author Commented:
not sure why you are looking online to create a file where you have tools locally

local server i cannot create new folders and files as i like.

How to create say a.txt and b.txt keep them in a folder called c then zip that as c.zip and search c.zip for a word count of "john" for example?
i tried as below
sh-4.4$ mkdir c                                                                                                                                    
sh-4.4$ ls -ltr                                                                                                                                    
total 8                                                                                                                                            
-rw-r--r-- 1 8169 8169  978 Nov 21 18:55 README.txt                                                                                                
drwxr-xr-x 2 8169 8169 4096 Nov 21 18:57 c                                                                                                        
sh-4.4$ cd c                                                                                                                                      
sh-4.4$ pwd                                                                                                                                        
/home/cg/root/c                                                                                                                                    
sh-4.4$ cat a.txt                                                                                                                                  
cat: a.txt: No such file or directory                                                                                                              
sh-4.4$ touch a.txt                                                                                                                                
sh-4.4$ touch b.txt                                                                                                                                
sh-4.4$ ls -ltr                                                                                                                                    
total 0                                                                                                                                            
-rw-r--r-- 1 8169 8169 0 Nov 21 18:58 a.txt                                                                                                        
-rw-r--r-- 1 8169 8169 0 Nov 21 18:58 b.txt                                                                                                        
sh-4.4$ cd ..                                                                                                                                      
sh-4.4$ ls -ltr                                                                                                                                    
total 8                                                                                                                                            
-rw-r--r-- 1 8169 8169  978 Nov 21 18:55 README.txt                                                                                                
drwxr-xr-x 2 8169 8169 4096 Nov 21 18:58 c
0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

gudii9Author Commented:
how to zip c folder?
zgrep already does this.

zgrep will search zipped or unzipped files

this i do not know
 does it show 2 times for example john is there in a.txt and also in c.zip which obviously has a.txt and b.txt as per above scenario?
0
arnoldCommented:
zip  c.zip c/*

-r  will replace items from c into the c.zip archive ......
0
Gerwin Jansen, EE MVETopic Advisor Commented:
How to create say a.txt and b.txt keep them in a folder called c then zip that as c.zip and search c.zip for a word count of "john" for example?

zgrep will not search trough a zip created archive to show you the result you want

zgrep searches for a string in one compressed file or you specify multiple files but not an archive.

If you use zgrep to search for a string in a zip archive, it will display this:

Binary file c.tar.Z matches

You would need to unzip the archive first. What is your real goal here?
0
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Choosing both these as related answers, the the various questions of poster.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.