Sponsored Content
Top Forums Shell Programming and Scripting Awk: Print Error While Redirecting output in multiple Files Post 302944654 by siramitsharma on Thursday 21st of May 2015 01:12:10 AM
Old 05-21-2015
Awk: Print Error While Redirecting output in multiple Files

Hi,
I have a following code in which I am unable to redirect to multiple files. Can anybody please help with some corrections

Code:
 awk -F, '{ if ( substr($1,26,2)=="02" && substr($1,184,14)=="MTSCC_VALFIRST") {
array1[substr($1,28,14)","substr($1,126,5)]++
array2[substr($1,126,5)]++
array3[substr($1,28,14)]++
 }
else if (substr($1,26,2)=="03" && substr($1,184,14)=="MTSCC_VALFIRST")
array4[substr($1,28,14)","substr($1,126,5)]++
}
END { for (counter1 in array1) {print counter1","array1[counter1] |"sort" } >"ValFirst_AO.txt"
 {for (counter2 in array2) { print counter2","array2[counter2] |"sort" > "ValFirst_MT.txt"} }
{for (counter3 in array3) {print counter3 ","array3[counter3]|"sort" >"ValFirst_SuccMT.txt"} }
{for (counter4 in array4) {print counter4","array4[counter4] |"sort" >"ValFirst_TotalMT.txt"} }
}
' 201505200900*
awk: cmd. line:10: END { for (counter1 in array1) {print counter1","array1[counter1] |"sort" } >"ValFirst_AO.txt"
awk: cmd. line:10:                                                                             ^ syntax error
awk: cmd. line:11:  {for (counter2 in array2) { print counter2","array2[counter2] |"sort" > "ValFirst_MT.txt"} }
awk: cmd. line:11:                                                                        ^ syntax error
awk: cmd. line:12: {for (counter3 in array3) {print counter3 ","array3[counter3]|"sort" >"ValFirst_SuccMT.txt"} }
awk: cmd. line:12:                                                                      ^ syntax error
awk: cmd. line:13: {for (counter4 in array4) {print counter4","array4[counter4] |"sort" >"ValFirst_TotalMT.txt"} }
awk: cmd. line:13:                                                                      ^ syntax error

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Redirecting output to multiple log files?

If I wanted to redirect output to multiple log files, what would be the best way to do that? echo "Unix is awesome" >>unixgod.log >>unixgod.log (3 Replies)
Discussion started by: darthur
3 Replies

2. UNIX for Dummies Questions & Answers

Redirecting UNIX Print Output

I am a new user to UNIX. We are currently running an application called DISC (www.disclink.com) on UNIX, and I am trying to figure out how to redirect print output to a PC printer. There is one little problem: DISC apparently has its own OS that is sitting on top of the UNIX OS, so you cannot... (1 Reply)
Discussion started by: BlueSpider
1 Replies

3. Shell Programming and Scripting

awk print fields to multiple files?

I am trying to print the output of a command to two separate files. Is it possible to use awk to print $1 to one file and $2 to another file? Thanks in advance! (1 Reply)
Discussion started by: TheCrunge
1 Replies

4. Shell Programming and Scripting

Redirecting to different output files with awk.

Well, it didn't take me long to get stumped again. I assure you that I'm not mentally deficient, just new to scripting. So, here's the gist. I want to redirect output from awk based off of which branch of an if-else statement under which it falls. #!/bin/bash #some variables... (2 Replies)
Discussion started by: mikesimone
2 Replies

5. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

6. Solaris

Redirecting print to optional output bins

Guys We have a HP P4015 laserjet printer with a 5 bin mailbox attached & configured. We can print to the specific output bins from Oracle e-Business suite, however our print output format is incompatible so it prints out random characters instead of the letter content. I have looked... (2 Replies)
Discussion started by: s1977
2 Replies

7. Shell Programming and Scripting

awk, multiple files input and multiple files output

Hi! I'm new in awk and I need some help. I have a folder with a lot of files and I need that awk do something in each file and print a new file with the output. The input file name should be modified when I print the outpu files. Thanks in advance for help! :-) ciao (5 Replies)
Discussion started by: gabrysfe
5 Replies

8. Shell Programming and Scripting

Compare columns of multiple files and print those unique string from File1 in an output file.

Hi, I have multiple files that each contain one column of strings: File1: 123abc 456def 789ghi File2: 123abc 456def 891jkl File3: 234mno 123abc 456def In total I have 25 of these type of file. (5 Replies)
Discussion started by: owwow14
5 Replies

9. Shell Programming and Scripting

awk script issue redirecting to multiple files after matching pattern

Hi All I am having one awk and sed requirement for the below problem. I tried multiple options in my sed or awk and right output is not coming out. Problem Description ############################################################### I am having a big file say file having repeated... (4 Replies)
Discussion started by: kshitij
4 Replies

10. Post Here to Contact Site Administrators and Moderators

Redirecting grep output to multiple files

Hi All, I am trying to redirect the grep output to multiple files, can you please help with that. Below is the command im using to match my pattern grep \<proxyType\>$PxyType $DIR/EndureFiles.json > File_Name*.json Note : $DIR and $PxyType is already defined in my script Im able... (0 Replies)
Discussion started by: Deena1984
0 Replies
ppmtosixel(1)                                                 General Commands Manual                                                ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 09:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy