Sponsored Content
Top Forums Shell Programming and Scripting Need some Help for file filteration and saving the output in other directory Post 302599910 by agama on Sunday 19th of February 2012 09:13:59 AM
Old 02-19-2012
No awk, that's very odd. Assuming you have Kshell or bash, have a go with this. Replace the directory names with yours (I used the ones here to test).

Code:
#!/usr/bin/env bash
# change the directory names to be your source, destination and filter
sdir=src     
ddir=dest
fdir=filter

# use find to prevent issues if there are a lot of *.txt files
find $sdir -name "*.txt" | while read file
do
    grep -f $fdir/filter $file >$ddir/${file##*/}
done

You might want to remove the line of dashes from your filter file since that is not a potential pattern in one of your source files you'll waste time with each line in each grep trying to match it.
This User Gave Thanks to agama For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Saving output from awk into a perl variable

How would I pass awk output to a perl variable? For example, I want to save the value in the 4th column into the variable called test. My best guess is something as follow, but I am sure this isn't correct. $test = system("awk '/NUMBER/{print \$4}' $_"); (8 Replies)
Discussion started by: userix
8 Replies

2. UNIX for Dummies Questions & Answers

saving command output to a variable

Hello, I have a shell script containing a command string in the following format: command1 | command2 | cut -c9-16 The output from this is a record number (using characters 9-16 of the original output string) e.g. ORD-1234 I wish to save this value to a variable for use in later commands... (4 Replies)
Discussion started by: philjo
4 Replies

3. UNIX for Dummies Questions & Answers

Saving a temporary output within a script

Good morning everyone, i am looking to know how to save the output of a command and reuse it again within a script i already tired this one but it didn't work TEMPDIR=/dir1/dir2 My_command> $TEMPDIR/$TEMPFILE rm $TEMPDIR/$TEMPFILE* it keeps saying "cannot write to a... (15 Replies)
Discussion started by: Portabello
15 Replies

4. Shell Programming and Scripting

saving output from bash into a file

I am ssh to many servers to get some information... however sometimes the server is unreacheable and i am getting an error. I want to save that output to a file but I am not able to do so... I want to be able to save output of bash into a file.. so when I run this command on a script ssh... (5 Replies)
Discussion started by: eponcedeleonc
5 Replies

5. Shell Programming and Scripting

Need help for file filteration script......

Hiii all... Pls help me out wid below prblm : i have 5 files A,B,C,D and E located at /home/anubha I have a file F located at /home/anubha/ed File F has some records which can be matched in A,B,C,D and E and another set of files on the basis of these filteration should be created i.e.... (5 Replies)
Discussion started by: ektubbe
5 Replies

6. Shell Programming and Scripting

Need some Help for file filteration and saving the output in other directory using grep....plz ...

Hi all........ Plss do help me.......in a big trouble... :wall::wall::wall: I have 3 directories named as :1. /home/shuchi/source 2./home/shuchi/destination 3./home/shuchi/filter now the problem is /home/shuchi/source has say 2 files with extension .txt as given below : A.txt Code: ... (0 Replies)
Discussion started by: ektubbe
0 Replies

7. Shell Programming and Scripting

Saving svn log in a separate directory

Hi Folks, I have a directory at /usr/local/aa and there is other directory where I have checkout the code through svn checkout command ( /opt/app/fgh) now I can apply svn log command here as shown below $ cd /opt/app/fgh svn checkout <url> svn log shows me the log on console . please... (3 Replies)
Discussion started by: punpun66
3 Replies

8. Shell Programming and Scripting

Saving nohup output to a file other than nohup.out

Shell : bash OS : Oracle Linux 6.4 I want to save the ouput of a nohup command to file other than nohup.out . Below are my 3 attempts. For both Attempt1 and Attempt2 , the redirection logs the output correctly to the output file. But I get the error "ignoring input and redirecting stderr to... (7 Replies)
Discussion started by: kraljic
7 Replies

9. Shell Programming and Scripting

Saving files with file name as output

Hi, i need help with a file creation of an output program. I've got a program that with #find creates an output for each files in a directory. If i give this command : -o spec$(date -u +%Y%m%dt%H%M) it creates just one file, overwriting all the others since it is the creation date .... (2 Replies)
Discussion started by: Board27
2 Replies

10. Shell Programming and Scripting

sed command is saving output as blank file

Hi, I am working on a script where I am adding adding colors to few of the info in the output. Now , after that is done , I see colour codes in log files which I don't want to see.:mad::mad::mad::mad: So , I tried using sed command in script as below which gives me o/p (new.log) as blank file... (7 Replies)
Discussion started by: Dream4649
7 Replies
evmfilterfile(4)					     Kernel Interfaces Manual						  evmfilterfile(4)

NAME
evmfilterfile - Event Manager filter file SYNOPSIS
DESCRIPTION
A filter file contains one or more filter descriptions, which can be referenced through certain EVM commands by using indirect filter syn- tax. An indirect filter specifier has the following form: In the previous indirect filter specifier, filename is the name of a filter file, and filter_name is the name of a filter contained in the file. If no filter_name is specified, the first filter in the file is used. By convention, filter file names should have the suffix If a command cannot find the file with the name as specified, it appends and tries again. If a relative pathname is given for a file, commands search for the file in each location specified by the environment variable if it is present. Otherwise the search is performed in the following standard locations in turn, stopping as soon as the file is found: o The current working directory o o Several supplied filter files, containing shortcut filters for many system events, can be found in the directory System administrators should place site-specific filter files in The filter file is made up of a series of keyword/value and keyword/group pairs. Values containing spaces must be enclosed in double quotes. Strings may be continued across a newline by finishing the line with a backslash character. Any portion of a line from an unquoted number sign to the end of line is a comment. Blank lines are ignored. The following keywords are recognized: Introduces a filter group. Names the filter. The filter_value is a string that conforms to EVM filter syntax. See the EvmFilter(5) manpage for information about filter syntax. Modifies the current filter_value. See the description of the and keywords below. Modifies the current filter_value. See the description of the and keywords below. The filter_title is a text string that describes the purpose of the filter. The title is not currently used, but always should be included. The and keywords can appear multiple times in a filter group, allowing you to build and maintain a filter in simple single-line increments. Each filter_element must be a valid filter string, conforming to the syntax described in the EvmFilter(5) manpage. A complete filter string is assembled by surrounding the initial filter with parentheses and appending the filter_elements to it, separating each with a log- ical (for or (for operator. For example: The previous filter lines are equivalent to this more complex single filter line: The first line selects all events with a priority of 200 or greater, the next modifies this by selecting all events from regardless of their priorities, and the last line excludes all events regardless of their priorities. If you prefer, you can omit the command, and build the complete filter string from and lines. Notes If you are concerned with allowing your file to be used on other systems that support EVM in the future, you should use the built-in macro in place of the first two components of the name of any system event. This will make it unnecessary to change the file if the other system uses a different event name prefix. EXTERNAL INFLUENCES
Environment Variables A colon-separated set of directory pathnames to be searched for a requested filter file. If this variable is present in the environment the directories are searched in place of the standard directories. EXAMPLES
1. The following is an example of a pair of entries in a filter file: 2. The following command finds and displays all EVM events, using a filter stored in the supplied filter file 3. Assuming that the filter file shown in the first example is named and is located in a standard filter directory, the following command displays the value of the filter from that file: FILES
Site-specific filter files. System filter files. SEE ALSO
Commands evmget(1), evmshow(1), evmwatch(1). Routines EvmFilterCreate(3), EvmFilterDestroy(3), EvmFilterIsFile(3), EvmFilterReadFile(3), EvmFilterSet(3), EvmFilterTest(3). Event Management EVM(5). EVM Events EvmEvent(5). Event Filter EvmFilter(5). evmfilterfile(4)
All times are GMT -4. The time now is 05:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy