![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sed redirection | myle | UNIX for Dummies Questions & Answers | 3 | 03-12-2008 04:04 PM |
| csh stderr redirection | jolok | Shell Programming and Scripting | 0 | 04-15-2005 07:03 AM |
| I/O redirection within a coprocess | Mugin | Shell Programming and Scripting | 4 | 10-21-2003 05:17 AM |
| Help with redirection | Shallon1 | High Level Programming | 2 | 12-12-2001 04:35 AM |
| redirection to tty** with cat | zorro | UNIX for Dummies Questions & Answers | 1 | 11-02-2001 08:23 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
try this.....
yourscript 2>&1 > somefile says take STDERR (2) and redirect to same place as STDOUT (&1)... |
|
#3
|
|||
|
|||
|
Quote:
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
|
|||
|
|||
|
you want to put that on your command line, not within the script!
|
|
#5
|
|||
|
|||
|
I only don't want that appear any errors on the screen.
Last edited by DNAx86; 04-18-2008 at 08:20 AM. |
|
#6
|
||||
|
||||
|
Code:
find $directory_iniziale -type f 2>/dev/null | .... |
|
#7
|
|||
|
|||
|
So I have to put 2> after every command?
Can I redirect all the errors to a file in all the script? |
|||
| Google The UNIX and Linux Forums |