The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sed redirection myle UNIX for Dummies Questions & Answers 3 03-12-2008 07:04 PM
csh stderr redirection jolok Shell Programming and Scripting 0 04-15-2005 10:03 AM
I/O redirection within a coprocess Mugin Shell Programming and Scripting 4 10-21-2003 08:17 AM
Help with redirection Shallon1 High Level Programming 2 12-12-2001 07:35 AM
redirection to tty** with cat zorro UNIX for Dummies Questions & Answers 1 11-02-2001 11:23 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-18-2008
DNAx86 DNAx86 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 69
redirection

Hi,

The code below works, it's a part of a bash shell script that serve to search a pattern $pattern_da_cercare in the files contained in a directory $directory_iniziale.

Now the proble is:
How can I redirect stderr to a file?
PS: so I want to redirect ALL the errors to a file.

I tryed to learn how to do it, but I haven't understood

Code:
find $directory_iniziale -type f | while read file 
do
  
  awk -v min=$MIN -v max=$MAX -v patt=$pattern_da_cercare '
  BEGIN{RS=" |\n"; patt = "(^|[^A-Za-z0-9])" patt "([^A-Za-z0-9]|$)" }
  $0 ~ patt {n++}
  END {
		if(n >= min && n <= max && n != 0) {print FILENAME " : " n}
  }
  ' "$file"

done
  #2 (permalink)  
Old 04-18-2008
quine quine is offline
Registered User
  
 

Join Date: Mar 2008
Location: Bay Area California
Posts: 68
try this.....


yourscript 2>&1 > somefile

says take STDERR (2) and redirect to same place as STDOUT (&1)...
  #3 (permalink)  
Old 04-18-2008
DNAx86 DNAx86 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 69
Quote:
Originally Posted by quine View Post
try this.....


yourscript 2>&1 > somefile

says take STDERR (2) and redirect to same place as STDOUT (&1)...
I inserted it in my script, but find still procude output errors on the screen and the error-file is empty

Code:
find $directory_iniziale -type f | while read file 2>&1 > conta_occorrenze_log.txt
do
  
  awk -v min=$MIN -v max=$MAX -v patt=$pattern_da_cercare '
  BEGIN{RS=" |\n"; patt = "(^|[^A-Za-z0-9])" patt "([^A-Za-z0-9]|$)" }
  $0 ~ patt {n++}
  END {
		if(n >= min && n <= max && n != 0) {print FILENAME " : " n}
  }
  ' "$file"

done
  #4 (permalink)  
Old 04-18-2008
denn denn is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 96
you want to put that on your command line, not within the script!
  #5 (permalink)  
Old 04-18-2008
DNAx86 DNAx86 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 69
Quote:
Originally Posted by denn View Post
you want to put that on your command line, not within the script!
I only don't want that appear any errors on the screen.

Last edited by DNAx86; 04-18-2008 at 11:20 AM..
  #6 (permalink)  
Old 04-18-2008
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Code:
find $directory_iniziale -type f 2>/dev/null | ....
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0