Visit Our UNIX and Linux User Community

awk two file redirection

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk two file redirection
# 1  
Old 12-18-2007
awk two file redirection


i use awk -F to print three variable delimited by comma $1 $2 $3

if $2=="" i want to extract this information missing from another file using awk -v + some process.

but the problem i can't use the two awk together cause of redirection

there's a solution.

note: i can't use another command like gawk.

the script is like that :

awk -F "," '{ {$1; $2; $3 }
if ($2 == "")
traitement }
traitement' file1 > file2

awk -v s="$string" 'BEGIN{

traitement to find $2
}' file3

can u suggest a solution to have the two awk in the same one ( file1 file2 file3 are not the same).

thanks for u
# 2  
Old 12-18-2007
You want to split file3 into two separate files: file1 & file2 based on what criteria?

Previous Thread | Next Thread
Test Your Knowledge in Computers #131
Difficulty: Easy
UNIX certification is based on the 'Single Unix Specification' which is an extension of IEEE 1003 (POSIX).
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk file redirection issue

So I'm writing a script which tries to parse human-readable addresses. Part of it is this: print $2, implode(A,1,AN," "), CITY, PROV, POST, COUNTRY, CITYCOUNT>2; CITYCOUNT is a variable between 0 and 3 counting the number of words in a city name. I'm trying to prnt 1 wherever that's greater... (5 Replies)
Discussion started by: Corona688
5 Replies

2. UNIX for Dummies Questions & Answers

little problem of file redirection (awk)

I almost reach my objective (Youhouuu !!!!) But I really don't understand why it doesn't work until the end... :wall: For clarity's sake I am taking a very simple example. The operations I am doing in the script (gsub and print) really don't have any importance !!! I just matter about... (10 Replies)
Discussion started by: beca123456
10 Replies

3. Shell Programming and Scripting

Output redirection of c binary file to a file in shell script is failing

I am struck up with a problem and that is with output redirection. I used all the ways for the redirection of the output of c binary to a file, still it is failing. Here are the different ways which I have used: ./a.out | tee -a /root/tmp.txt 2>&1 ./a.out | tee -a /root/tmp.txt 1>&1 ./a.out |... (2 Replies)
Discussion started by: Maya29988
2 Replies

4. Shell Programming and Scripting

awk redirection

Hi everyone i am facing a very strange problem . see below is my code #awk <do something> file 1 > file2 Now the problem is whenever i am redirecting the output to file2 it creates the file2 but of 0 size. i don't know what is the reason but it is very important to me to redirect the... (11 Replies)
Discussion started by: aishsimplesweet
11 Replies

5. Shell Programming and Scripting

awk output redirection to file

I have a system stat command running which generates data after 5 sec or so. I pass this data to awk and do some calculation to present the data differently. Once done now I want to pass this data to file as and when generated but doesn't work..unless the first command completes successfully.... (6 Replies)
Discussion started by: learnscript
6 Replies

6. Shell Programming and Scripting

Error with redirection in awk

I'm trying to find average of values in 2nd column in some files. Filenames have following pattern eg: tau_2.54_even_v1.xls tau_2.54_odd_v1.xls tau_1.60_v1.xls tau_800_v1.xls #!/bin/bash for file in pmb_mpi tau xhpl mpi_tile_io fftw ; do for f in "2.54" "1.60" "800" ;do if... (2 Replies)
Discussion started by: vishwamitra
2 Replies

7. Shell Programming and Scripting

awk print redirection to variable file name

Hello, i need to redirect the output of print to a variable file name: #This is normal awk '{ print $17 > "output.txt" }' input #I need something like this awk '{ print $17 > "output_${25}.txt" }' input how to format the output file name to contain a variable? (6 Replies)
Discussion started by: nazeeb
6 Replies

8. Shell Programming and Scripting

file redirection problem

my querry is suppose i have duplicate std i/p with FD-3 --exec 0<&3 now redirected std i/p to a file ----exec 0<file1 suppose i am reading the file line by line --while read LINE cutting some fields and comparing it with a variable and if a match is found ... (0 Replies)
Discussion started by: mobydick
0 Replies

9. Shell Programming and Scripting

Tail -f, awk and redirection

I want to run tail -f to continuously monitor a log file, outputing a specific field to a second log file. I can get the first portion to work with the following command: tail -f log | awk '{if ($1 == "Rough") print $5}' also: awk '{if ($1 == "Rough") print $5}' <(tail -f log) The... (2 Replies)
Discussion started by: mfajer
2 Replies

10. UNIX for Dummies Questions & Answers

File redirection

Is it possible to sh a command and receive the standard output on the scrren and use file redirection ie ls -lt > test. Also On SCO-UNIX there was a tellme command which displayed a message when a script had finished running is there something similar for HP UNIX as it is not working. (4 Replies)
Discussion started by: namtab
4 Replies

Featured Tech Videos