Sponsored Content
Full Discussion: awk command error in Solaris
Operating Systems Solaris awk command error in Solaris Post 302996711 by Raul_Rodriguez on Monday 1st of May 2017 09:33:10 AM
Old 05-01-2017
awk command error in Solaris

I have the following code that works perfectly in Cygwin
Code:
$ awk -F, '
 BEGIN   {months ["JAN"]="AP01"; months ["FEB"]="AP02"; months ["MAR"]="AP03";
          months ["APR"]="AP04"; months ["MAY"]="AP05"; months ["JUN"]="AP06";
          months ["JUL"]="AP07"; months ["AUG"]="AP08"; months ["SEP"]="AP09";
          months ["OCT"]="AP10"; months ["NOV"]="AP11"; months ["DEC"]="AP12";
         }
         {TMP = FILENAME
          sub (/\..*$/, "", TMP)
          print> "a_" TMP "_ACTUAL_"months[substr($3,0,3)]"-20" substr($3,5,2)"_RR.txt"
         }
 ' *.txt

This codes splits any txt file into multiple txt files based on field number three. The new files are named using a portion of the original file and the Accounting Periods (AP) listed at the beginning of the script.
As I move the script to the server (Solaris) it generates a syntax error during execution. The error reads: Syntax error near line 7. Line 7 is the assignment of the current filename to the TMP variable.

As I mentioned this is not an issue in Cygwin. The script runs as expected but not so in Solaris. Any help will be greatly appreciated
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Solaris 9: make: Fatal error:Command failed for target

Hi everyone first of all you should know that I've been working with solaris for a few days only. :) I need to install some programs and I have had the following troubles: 1. When I used /.configure it showed the following message: "no acceptable C compiler found in $PATH" I included... (2 Replies)
Discussion started by: eldiego
2 Replies

2. Shell Programming and Scripting

error in awk command

ls filename*.txt | awk -F".Y" '$2 < $v_RUN_DT && $2 > $v_LOAD_DT'|awk ' NR==1' I am getting this error . Can somebody plz point me where is the problem. awk: 0602-562 Field $() is not correct. The input line number is 1. The source line number is 1. (16 Replies)
Discussion started by: RubinPat
16 Replies

3. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

Hello all, Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val: > cat getnon0file.sh #!/bin/bash this="getnon0file.sh" USAGE=$this" InFile="xyz.38" Min="0.05" # awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies

4. Shell Programming and Scripting

awk script Error in Sun Solaris

Hi Friends, the below script has been through the errors in sun solaris. awk '/%s/{f=0 ;n++; print >(file="OUT_" n); close("OUT_" n-1)} f{ print > file}; /%s/{f=1}' $BASE_DIR/concat.TXT awk: syntax error near line 1 awk: bailing out near line 1 And ls $MERGE_DIR/*.R | awk ' { ... (2 Replies)
Discussion started by: krbala1985
2 Replies

5. Solaris

Error during running sqlplus command from shell script in Solaris

I am using following code to connect to oracle database from solaris shell script. which will try thrice to connect the database ...at the 4rth atempt it will exir=t. count=0 while ; do sqlplus -s $usrname/$password@dbSID <<-EOF | tee $logfile WHENEVER OSERROR EXIT 9; WHENEVER SQLERROR... (4 Replies)
Discussion started by: millan
4 Replies

6. Shell Programming and Scripting

Getting syntax error while running awk command

Hello Gurus, I am firing the below command : df -g | grep -v var| awk '{ (if $4 > 90% ) print "Filesystem", $NF,"over sized";}' But I am getting the below error:- ====== syntax error The source line is 1. The error context is {if ($4 > >>> 90%) <<< awk: The... (9 Replies)
Discussion started by: pokhraj_d
9 Replies

7. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

8. Shell Programming and Scripting

Bash script with awk command ERROR

Hello im new here... Im trying to read file and create folders from words in it but i get this for loop error awk : line 3 : syntax error at or near for my code is.. #!/bin/bash begin for (( i=1;i<=5;i++)); do awk -v i=$i $0 { print $i } mkdir $i done {print $i} end {} i have... (7 Replies)
Discussion started by: boxstep
7 Replies

9. Shell Programming and Scripting

Spot error with my awk command

can any one identify why this command keeps resulting in 1, even though the string i'm searching for actually does not exist in the log? awk 'BEGIN{count++} NR>220 && NR<=223 && /error/ && !/No.*such.*file.*or.*direfctory/ { count++ } END { print count }' /var/log/mail.log i expected it to... (2 Replies)
Discussion started by: SkySmart
2 Replies

10. Shell Programming and Scripting

Issue with awk command between Linux and Solaris

Hi, Here is the output using bash profile on Linux uptime 04:59:14 up 16 days, 4:48, 2 users, load average: 1.00, 1.00, 1.20 Here is the output using bash profile on Solaris uptime 4:00am up 84 day(s), 22:21, 3 users, load average: 0.09, 0.10, 0.12 Now,... (4 Replies)
Discussion started by: mohtashims
4 Replies
atprint(3)						       AtFS Toolkit Library							atprint(3)

NAME
atWriteStatus, atWriteMode, atWriteDate, atWriteName, atScanStatus - print and scan special attribute values SYNOPSIS
#include <atfs.h> #include <atfstk.h> char*atWriteStatus (Af_key *aso; int verbose); char*atWriteMode (Af_key *aso); char*atWriteDate (Af_key *aso, char *dateAttribute); char*atWriteName (Af_key *aso, char *path); int atScanStatus (char *statusStr); DESCRIPTION
atWriteStatus returns a string representation of Asos AF_STATE attribute. With the verbose argument TRUE, atWriteStatus returns a long (8 character) status name. Otherwise, on FALSE, it returns a one character short representation. The result value is a statically defined string in any case. atWriteMode generates a ls -l(1) like (e.g. -rwxr-xr-x) string representation of the AF_MODE attribute. It returns its result in static memory, which will be overwritten on subsequent calls. atWriteDate produces a date string from the given dateAttribute to be used for ls -l(1) like output (e.g. Jan 8 11:07 or Jul 10 1992). The format of the date string depends on the value of the date attribute. The string is always 12 characters long and begins with the month and day. For dates younger than 6 months, the third field is the time, for dates older than 6 months, the year. The result string resides in static memory, which will be overwritten on subsequent calls. atWriteName generates a bound pathname from path and aso. atScanStatus converts an status string to an internal numeric status value. It understands various abbreviations, including the one charac- ter status strings generated by atWriteStatus. .BUGS The format switch in afWriteDate (for dates older than six months) does not happen at exactly the right time. It may be a few days later. AtFStk-1.12 Fri Jun 25 16:39:43 1993 atprint(3)
All times are GMT -4. The time now is 03:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy