Sponsored Content
Top Forums Shell Programming and Scripting Awk: Print Error While Redirecting output in multiple Files Post 302944656 by siramitsharma on Thursday 21st of May 2015 02:06:03 AM
Old 05-21-2015
Still the same

Code:
 awk '{
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" } }
' 201505200900*
awk: cmd. line:11: END { for (counter1 in array1) {print counter1","array1[counter1] |"sort" >"ValFirst_AO.txt" } }
awk: cmd. line:11:                                                                           ^ 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
ARRAY_DIFF_UKEY(3)							 1							ARRAY_DIFF_UKEY(3)

array_diff_ukey - Computes the difference of arrays using a callback function on the keys for comparison

SYNOPSIS
array array_diff_ukey (array $array1, array $array2, [array $...], callable $key_compare_func) DESCRIPTION
Compares the keys from $array1 against the keys from $array2 and returns the difference. This function is like array_diff(3) except the comparison is done on the keys instead of the values. Unlike array_diff_key(3) a user supplied callback function is used for the indices comparison, not internal function. PARAMETERS
o $array1 - The array to compare from o $array2 - An array to compare against o $... - More arrays to compare against o $key_compare_func - The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. int callback (mixed $a, mixed $b) RETURN VALUES
Returns an array containing all the entries from $array1 that are not present in any of the other arrays. EXAMPLES
Example #1 array_diff_ukey(3) example <?php function key_compare_func($key1, $key2) { if ($key1 == $key2) return 0; else if ($key1 > $key2) return 1; else return -1; } $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); var_dump(array_diff_ukey($array1, $array2, 'key_compare_func')); ?> The above example will output: array(2) { ["red"]=> int(2) ["purple"]=> int(4) } NOTES
Note This function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using array_diff_ukey($array1[0], $array2[0], 'callback_func');. SEE ALSO
array_diff(3), array_udiff(3), array_diff_assoc(3), array_diff_uassoc(3), array_udiff_assoc(3), array_udiff_uassoc(3), array_diff_key(3), array_intersect(3), array_intersect_assoc(3), array_intersect_uassoc(3), array_intersect_key(3), array_intersect_ukey(3). PHP Documentation Group ARRAY_DIFF_UKEY(3)
All times are GMT -4. The time now is 09:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy