Sponsored Content
Top Forums Shell Programming and Scripting Need some Help for file filteration and saving the output in other directory Post 302600640 by agama on Tuesday 21st of February 2012 05:20:09 PM
Old 02-21-2012
If you could paste the script you are using it would help. Possibly a typo in the script. You could also try running a grep by hand to see what it yields.

Assuming one of the files that find will list is foo.txt, try running this to see what happens:


Code:
grep -f filter-file-name foo.txt|more

If you see output from this command, then your script likely has a bug. No output could mean that there was nothing in foo.txt to find, or the filter file is wrong.

Hard to say more without seeing your script.
 

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
STREAM_FILTER_REGISTER(3)						 1						 STREAM_FILTER_REGISTER(3)

stream_filter_register - Register a user defined stream filter

SYNOPSIS
bool stream_filter_register (string $filtername, string $classname) DESCRIPTION
stream_filter_register(3) allows you to implement your own filter on any registered stream used with all the other filesystem functions (such as fopen(3), fread(3) etc.). PARAMETERS
o $filtername - The filter name to be registered. o $classname - To implement a filter, you need to define a class as an extension of php_user_filter with a number of member functions. When performing read/write operations on the stream to which your filter is attached, PHP will pass the data through your filter (and any other filters attached to that stream) so that the data may be modified as desired. You must implement the methods exactly as described in php_user_filter - doing otherwise will lead to undefined behaviour. RETURN VALUES
Returns TRUE on success or FALSE on failure. stream_filter_register(3) will return FALSE if the $filtername is already defined. EXAMPLES
Example #1 Filter for capitalizing characters on foo-bar.txt stream The example below implements a filter named strtoupper on the foo-bar.txt stream which will capitalize all letter characters writ- ten to/read from that stream. <?php /* Define our filter class */ class strtoupper_filter extends php_user_filter { function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $bucket->data = strtoupper($bucket->data); $consumed += $bucket->datalen; stream_bucket_append($out, $bucket); } return PSFS_PASS_ON; } } /* Register our filter with PHP */ stream_filter_register("strtoupper", "strtoupper_filter") or die("Failed to register filter"); $fp = fopen("foo-bar.txt", "w"); /* Attach the registered filter to the stream just opened */ stream_filter_append($fp, "strtoupper"); fwrite($fp, "Line1 "); fwrite($fp, "Word - 2 "); fwrite($fp, "Easy As 123 "); fclose($fp); /* Read the contents back out */ readfile("foo-bar.txt"); ?> The above example will output: LINE1 WORD - 2 EASY AS 123 Example #2 Registering a generic filter class to match multiple filter names. <?php /* Define our filter class */ class string_filter extends php_user_filter { var $mode; function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { if ($this->mode == 1) { $bucket->data = strtoupper($bucket->data); } elseif ($this->mode == 0) { $bucket->data = strtolower($bucket->data); } $consumed += $bucket->datalen; stream_bucket_append($out, $bucket); } return PSFS_PASS_ON; } function onCreate() { if ($this->filtername == 'str.toupper') { $this->mode = 1; } elseif ($this->filtername == 'str.tolower') { $this->mode = 0; } else { /* Some other str.* filter was asked for, report failure so that PHP will keep looking */ return false; } return true; } } /* Register our filter with PHP */ stream_filter_register("str.*", "string_filter") or die("Failed to register filter"); $fp = fopen("foo-bar.txt", "w"); /* Attach the registered filter to the stream just opened We could alternately bind to str.tolower here */ stream_filter_append($fp, "str.toupper"); fwrite($fp, "Line1 "); fwrite($fp, "Word - 2 "); fwrite($fp, "Easy As 123 "); fclose($fp); /* Read the contents back out */ readfile("foo-bar.txt"); ?> The above example will output: LINE1 WORD - 2 EASY AS 123 SEE ALSO
stream_wrapper_register(3), stream_filter_append(3), stream_filter_prepend(3). PHP Documentation Group STREAM_FILTER_REGISTER(3)
All times are GMT -4. The time now is 03:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy