Home Man
Today's Posts

The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

Help with Script using awk


Login to Reply

Thread Tools Search this Thread
# 8  
Old 09-08-2017
Hi All,

Amazing what a wee nights sleep can do....

I found my issue was trying awk in the if statement, so changed it and amended it to what I need...

. . .
LIST=`ls -1 POM* 2>/dev/null`
. . .

for FILE in $LIST
    awk -F"," ' { if( NF > 14){ print FILENAME" line:> " NR }}' $FILE >> $OUTPUT

this work perfect for what I need it for...

Thanks for all your suggestions.


P.s. Yes still on Solaris 10 but moving to 11 later in the year.
# 9  
Old 09-14-2017
If you do not use $LIST elsewhere you can do
. . .
. . .

for FILE in POM*
    [ -f "$FILE" ] || continue
    awk -F"," '{ if (NF > 14) { print FILENAME" line:> " NR } }' "$FILE"
done > $OUTPUT

The whole output stream is redirected to $OUTPUT, this is more efficient than many times append it.
The globbing in the for requires a test to ensure presence, but the test also ensures that it's a real file (not a directory) which makes it more robust.
Have $FILE in quotes, or the shell attempts to expand it.
The Following User Says Thank You to MadeInGermany For This Useful Post:
dakelly (10-02-2017)
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell script works fine as a standalone script but not as part of a bigger script ektubbe Shell Programming and Scripting 2 07-11-2017 12:13 PM
Calling a script from master script to get value from called script Raj Roy UNIX for Dummies Questions & Answers 2 03-14-2014 11:29 AM
Script will keep checking running status of another script and also restart called script at night ketanraut Shell Programming and Scripting 1 11-20-2013 09:41 AM
create a shell script that calls another script and and an awk script magikminox Shell Programming and Scripting 0 06-26-2008 02:50 AM

All times are GMT -4. The time now is 05:22 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
Show Password