Unix-How to Grep inside PKZIP files? - grep

I would like to do a grep inside my zip file.
While i was trying with zgrep it doesn't work because when I tried with command
File
It returns the file as PKZIP: compressed archive
Zgrep doesn't work under pkzip files it seems.
Can any one help me on this?

One (heavy) method, if you have multiple grep to do, is to mount your zip with fuse-zip and grep files in the mounted directory.

Related

Using fgrep with .txt as argument

Sorry if it is a duplicate, but I really couldn't find an answer.
How could I solve this one: I have a base .txt file (base.txt), and I want to perform the command "cat base.txt | fgrep string_to_find.txt", where string_to_find.txt contains the string I want to use with fgrep. I have a lot of string_to_find.txt files, so I can't do it one by one manually, I have to automate the task, most probably with a bash script.
Thanks!
Since the .txt file contains exactly the string I want to search, just solved with cat base.txt | fgrep "$(cat string_to_find.txt)".

Need a little help, I need correct syntax for grep and copy

I currently have 3TB of data on a disk with small to medium files in hundreds of folders.
I need to find certain text files witch contain certain words ( more than one word ).
I've already tried grep-ping for them.
This works as it prints the path to every file.
But this is a long list and I'm now looking for a workable way to copy them to another folder.
any ideas ?
Is there some way to put -exec cp -rv /estinationfolder in the syntax and have it copy all results to the folder ?
Yes , certainly there is a way.
You can pipe the grep output to copy command and provide required destination directory.
Here is a example,
find . -type f | xargs grep -l "textToSearch" | cpio -pV $destination_path
this script will copy files to destination path provided in destination_path variable
Best part with this is, it will copy the files while preserving the full path.

tar listing only files of an archive and not directories

How do I list only the contents of a tar file that are actual files or links to files and not directories?
I ask this because I want to take the tar -tf of an archive then retrieve the files in it from another directory.
One option (assuming you are on a *NIX system) is to parse and filter the output from a verbose listing
tar -tvf abc.tar | awk '!/^d/ {print $NF}'
Although this is fraught with all the perils of parsing ls output

save .trace file to a different location

I'm running instruments from command line. In my command, i did specified the output path
using
-e UIARESULTSPATH /user/xxxx
However, the files saved to the location above are plist liles. the .trace (ie. instrumentscli14.trace) files are automatically saved to the folder i save my scripts.
Do anyone know is there a way to save the .trace files to a custom location?
Thanks!
Do anyone know is there a way to save the .trace files to a custom
location?
Use the -D option, like this:
-D TestResults/TestTrace/theTrace.trace
I found that -D option is not working, but instruments saves trace file to current directory where you run command from..

How can I extract all localizable strings from all XIB files into one file?

I am looking for a way of extracting all localizable strings from .xib files and have all of them saved in a single file.
Probably this involves ibtool but I was not able to determine a way of merging all these in only one translation dictionary (could be .strings, .plist or something else).
Open terminal and cd to the root directory of the project (or directory where you store all XIB files) and type in this command:
find . -name \*.xib | xargs -t -I '{}' ibtool --generate-strings-file '{}'.txt '{}'
The magic is the find and xargs commands working together. -I option generates placeholder. -t is just for verbose output (you see what commands has been generated and executed).
It generates txts files with the same name as xib files in the same directory.
This command can be improved to concatenate output into one file but still is a good starting point.
Joining them together:
You can concatenate those freshly created files into one using similar terminal command:
find . -name \*.xib.txt | xargs -t -I '{}' cat '{}' > ./xib-strings-concatenated.txt
This command will put all strings into one file xib-strings-concatenated.txt in root directory.
You can delete generated partial files (if you want) using find and xargs again:
find . -name \*.xib.txt | xargs -t -I '{}' rm -f '{}'
this is a lot easier now.
in xcode, select your project (not a target)
then use menu/editor/export for localisation
xcode will output an xliff file with all localisable strings from your entire project.

Resources