The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
To generate the FTP Script file konankir Shell Programming and Scripting 1 04-01-2008 03:16 PM
Script to generate text file from excel file isingh786 UNIX for Dummies Questions & Answers 1 01-24-2008 10:32 AM
generate new string from a text file walterwaston Shell Programming and Scripting 6 10-16-2007 03:43 PM
Generate csv file rahulrathod Shell Programming and Scripting 4 01-23-2007 10:34 AM
How to generate an image file from FD Esteban UNIX for Advanced & Expert Users 1 12-22-2005 11:50 PM

Closed Thread
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
  #1 (permalink)  
Old 08-16-2006
mape mape is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 6
generate file incremented by 1

Hi

I a really need help.
I got simply shell script which store result into the specific file
in this case xxx_001.txt

And after another run script I would like to create the same file but
value 001 is incremented by 1 -> xxx_002.txt a so on.

If I gonna use awk utility then result is not 002 but only 2,
what is wrong.
-------------------------------------------
#!/usr/bin/ksh

file=xxx_001.txt

echo "give me sth" >> $file
------------------------------------------

Thanks

Mape
  #2 (permalink)  
Old 08-16-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,121
I don't understand why you need 'awk' and I don't see any 'awk' in your script.
  #3 (permalink)  
Old 08-16-2006
mape mape is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 6
awk is not used in script.
It is a just comment.

But how to solve this problem?
  #4 (permalink)  
Old 08-16-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,121
here's an idea - you can take it from here.
Code:
#!/bin/ksh

pivot='/tmp/.fileCount'

typeset -Z3 cnt=1

if [ -f "${pivot}" ]; then
   read cnt < "${pivot}"
fi

echo "cnt->[${cnt}]"
cnt=$(( cnt + 1 ))
echo "${cnt}" > "${pivot}"
  #5 (permalink)  
Old 08-17-2006
mape mape is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 6
perfect job,

its a really work fine.

Thanks a lot.
Closed Thread

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 02:57 PM.


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