Command output redirection to file issues


Login or Register to Reply

 
Thread Tools Search this Thread
# 8  
You could also replace code like this:-
Code:
for file in *
do
   if [ "$file" = "File_A" ]
   then
      echo "Found A" >> logfile.txt
   fi
   if [ "$file" = "File_B" ]
   then
      echo "Found B" >> logfile.txt
   fi
   if [ "$file" = "File_C" ]
   then
      echo "Found C" >> logfile.txt
   fi
done

.... with something like this:-
Code:
for file in *
do
   if [ "$file" = "File_A" ]
   then
      echo "Found A"
   fi
   if [ "$file" = "File_B" ]
   then
      echo "Found B"
   fi
   if [ "$file" = "File_C" ]
   then
      echo "Found C"
   fi
done > logfile.txt 2> logfiles.err

It's terrible dummy code, I know, but it has one output redirection and all STDOUT from the loop goes to it.

Does that give you something to work with to smarten your code?



Robin
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Command output redirection in script not working
haritha.gorijav
I need to count the number of lines in a .txt file and put it in a variable. I am using the following code #!/bin/bash count = $(wc -l "some file.txt" | awk '{print$1}') echo $count It is giving the following error. line3: count: command not foundWhat am I doing wrong here? :confused:... Shell Programming and Scripting
7
Shell Programming and Scripting
output redirection command
knowledgeSeeker
Dear All, ./waf --run scratch/myfirst > log.out 2>&1 The above is a command line to redirect the output to a file called log.out. what is the 2>&1 part for ? Thank you... UNIX and Linux Applications
2
UNIX and Linux Applications
Help with tar --append command output redirection
pganguly46
I am using tar command to append daily database backups on tape. "tar --append " command help me to do this. But tar --append command does not produce any output on stdout if it succeed. I want the output for that appended command to a log file. This log file should contain only the name of the...... Shell Programming and Scripting
0
Shell Programming and Scripting
Output file redirection
aagajaba
Suppose I have a file named a When I write cat a>a The following error message is displayed cat: a: input file is output file and my file a is truncated to zero size. Also the exit status of the last command is 1 Can someone tell me what actually happens when I do so?... UNIX for Dummies Questions & Answers
1
UNIX for Dummies Questions & Answers
Redirection of output to a log file
JohnCrump
Apologies for the trivial nature of this question but I cannot seem to get a simple re direct to a log file to work Step 1 touch log.txt at -f batch.sh now >> log.txt I am trying to get the batch.sh contents into the log file Manny Thanks... UNIX for Dummies Questions & Answers
8
UNIX for Dummies Questions & Answers
cvcredir(7D)							      Devices							      cvcredir(7D)

NAME
cvcredir - virtual console redirection driver
DESCRIPTION
The cvcredir virtual console redirection driver is a STREAMS-based pseudo driver that supports the network console provided on some plat- forms. The cvcredir driver interfaces with the virtual console driver cvc(7D), and the virtual console daemon, cvcd(1M). The cvcredir driver receives console output from cvc and passes it to cvcd. It receives console input from cvcd and passes it to cvc.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Architecture |Sun Enterprise 10000 | | |servers, Sun Fire 15K | | |servers | +-----------------------------+-----------------------------+ |Availability |SUNWcvc.u | +-----------------------------+-----------------------------+
SEE ALSO
cvcd(1M), attributes(5), console(7D), cvc(7D) Sun Enterprise 10000 SSP Reference Manual Sun System Management Services (SMS) Reference Manual SunOS 5.11 15 Sep 2000 cvcredir(7D)

Featured Tech Videos