Exclude particular files from strings output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Exclude particular files from strings output
# 1  
Old 12-18-2016
Question Exclude particular files from strings

Hi everyone,

Is it possible to have the command strings exclude particular files?

Here is what I am currently writing:
Code:
strings *20161212*

It prints all files in the directory, which is good, but some file types do not need to be printed because they contain gibberish. I am trying the below to exclude all the files with a .out extension, but it does not work:
Code:
 strings *20161212 ! '*.out'

Any ideas?

Last edited by clippertm; 12-18-2016 at 11:31 PM..
# 2  
Old 12-19-2016
Please, test the following:
Code:
find . -path './*' -prune -type f -name '*20161212*' ! -name '*.out' -exec strings {} +

This User Gave Thanks to Aia For This Post:
# 3  
Old 12-19-2016
Hi Aia,

Thanks! That works well. I am not familiar with find, how would you add a grep in there?
# 4  
Old 12-19-2016
Quote:
Originally Posted by clippertm
Hi Aia,

Thanks! That works well. I am not familiar with find, how would you add a grep in there?
Pipe it?
Code:
find . -path './*' -prune -type f -name '*20161212*' ! -name '*.out' -exec strings {} + | grep something

This User Gave Thanks to Aia For This Post:
# 5  
Old 12-19-2016
Excellent, thanks again Aia, this is very helpful.
# 6  
Old 12-19-2016
In recent shells,
Quote:
if the extglob shell option is enabled using the shopt builtin, several extended pattern matching operators are recognized
(cf man bash).
Try
Code:
shopt -s extglob
strings *20161212!(*.out)

You may have to adapt the pattern, and YMMV.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to pass strings from a list of strings from another file and create multiple files?

Hello Everyone , Iam a newbie to shell programming and iam reaching out if anyone can help in this :- I have two files 1) Insert.txt 2) partition_list.txt insert.txt looks like this :- insert into emp1 partition (partition_name) (a1, b2, c4, s6, d8) select a1, b2, c4, (2 Replies)
Discussion started by: nubie2linux
2 Replies

2. UNIX for Beginners Questions & Answers

Using find to output list of files with specific strings

This is my problem, I am using the following code to extract the file names with specific strings 0.01: find ./ -name "*.txt" -exec grep -H '0.01' {} + It works wonders with a small sample. However, when I use it in a real scenario it produces an empty file -even though I am sure there are... (11 Replies)
Discussion started by: Xterra
11 Replies

3. Shell Programming and Scripting

Perl script to find process and exclude strings from the output

Hi team, I'm a newbie of Perl Script and looking to create a simple perl script that will run in the Linux system: 1) to find process, such as ps -ef | grep process name 2) to exclude strings from the output if it found, for instance if i see abc from usr process, then will exclude it from... (1 Reply)
Discussion started by: hoffman2503
1 Replies

4. Shell Programming and Scripting

Grep strings on multiple files and output to multiple files

Hi All, I want to use egrep on multiple files and the results should be output to multiple files. I am using the below code in my shell script(working in Ksh shell). However with this code I am not attaining the desired results. #!/bin/ksh ( a="/path/file1" b="path/file2" for file in... (4 Replies)
Discussion started by: am24
4 Replies

5. Shell Programming and Scripting

Exclude lines in a file with matches with multiple Strings using egrep

Hi I have a txt file and I would like to use egrep without using -v option to exclude the lines which matches with multiple Strings. Let's say I have some text in the txt file. The command should not fetch lines if they have strings something like CAT MAT DAT The command should fetch me... (4 Replies)
Discussion started by: Sathwik
4 Replies

6. Shell Programming and Scripting

Exclude files in ls

Hi, I need to exlucde the files which are present in exclude.txt from a directory exlcude.txt AUZ.txt AUZ.chk NZ.txt NZ.chk tried with below code but not working ls -ltr | grep -v `cat exclude.lst` (9 Replies)
Discussion started by: rohit_shinez
9 Replies

7. Shell Programming and Scripting

Need to exclude .NFSxxx files in clear old files batch script

I am new to Shell Scripting and need some help. The following batch job has been failing for me due to the .nfsxxx files in use. I need to know how to modify the following script to exclude the .nfsxxx files so this batch job will not fail on me. I have done lots of googling and keep coming back... (2 Replies)
Discussion started by: kimberlyg2007
2 Replies

8. Shell Programming and Scripting

Exclude Certain Entries from Piped or Redirected Output?

I want to execute a command something like: find / -name "jni.h" and I want to direct the output of that command to some type of filter that will leave out all the lines reporting inaccessible directories (permission unavailable). Is this a pipe or a redirect? For example, output like... (1 Reply)
Discussion started by: downplay
1 Replies

9. UNIX for Dummies Questions & Answers

list the files but exclude the files in subdirectories

If I execute the command "ls -l /export/home/abcde/dev/proj/code/* | awk -F' ' '{print $9}' | cut -d'/' -f6-8" it will list all the files in /export/home/abcde/dev/proj/code/ directory as well as the files in subdirectories also proj/code/test.sh proj/code/test1.c proj/code/unix... (8 Replies)
Discussion started by: shyjuezy
8 Replies

10. UNIX for Advanced & Expert Users

du (exclude files)

Hi, I want to get the disk usage of a directory. But I want it to ignore a particular directory within it. Lets say I want disk usage of all files/dirs within dir1 except those that are named .snapshot Does du have the option of excluding a particular directory. (1 Reply)
Discussion started by: the_learner
1 Replies
Login or Register to Ask a Question