The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
DB Solo 3.0 (Default branch) iBot Software Releases - RSS News 0 02-26-2008 04:00 PM
DB Solo 3.0 Beta 1 (Default branch) iBot Software Releases - RSS News 0 01-22-2008 09:10 PM
script works on command line, not in cron job JackTheTripper UNIX for Dummies Questions & Answers 7 06-27-2007 02:51 AM
works from cmd-line but not in script OFFSIHR Shell Programming and Scripting 4 10-18-2006 09:41 AM
Appending line with sed works on Linux but not on Solaris nir_s Shell Programming and Scripting 4 08-11-2005 04:00 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 08-20-2006
nortypig nortypig is offline
Registered User
  
 

Join Date: Aug 2006
Location: Hobart Tasmania
Posts: 58
Line works in solo but not in program?

Now I am just getting frustrated and confused... if anyone has some advice on how this anomoly is occurring I would greatly appreciate it.

Code:
cat helpme.txt | awk 'NR<5{printf("%-20s %-20d %-20d %-20.1f\n","hello",$1,$2,$3)}' | sort -rk4
This line works fine in solo - reads the three fields from helpme.txt and adds a first field "hello" before the others on output... seems simple enough and it works fine on its own on the command line.

In a small program it doesn't work...

Code:
#!/bin/sh

echo "Please enter the file you want compressed: \c"; read filename 

echo File: $filename

# check to see file exists and is readable with -r
if [ -r $filename ]
then

echo gzip | gzip -f $filename; gunzip -l $filename.gz > $filename.txt; gunzip $filename
gzip -f rose.bmp; gunzip -l rose.bmp.gz >> $filename.txt; gunzip rose.bmp.gz

cat helpme.txt | awk 'NR<5{printf("%-20s %-20d %-20d %-20.1f\n","hello",$1,$2,$3)}' | sort -rk4

else

echo sorry the file does not exist or is not readable

fi
So at this point I am thinking magic?

And yes with only the three fields in the short program it does work fine.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:23 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0