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
what is -u option in while loop in unix krishna_gnv Shell Programming and Scripting 1 05-20-2008 03:08 AM
Unix Loop from a file dkranes Shell Programming and Scripting 4 04-06-2007 04:36 PM
Unix-Sql Loop error manu_byc Shell Programming and Scripting 3 02-05-2007 09:40 AM
Please help with UNIX while loop... gerard1 Shell Programming and Scripting 1 02-01-2005 12:39 PM
timing a loop in unix. wolkott Shell Programming and Scripting 1 02-04-2003 02:52 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 04-29-2008
deep_kol deep_kol is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 14
for loop in unix

hi,
can any one suggest why the program 2 is not working.
only difference is

for ab in *.txt
for ab in a_DATA.txt b_DATA.txt c_DATA.txt
------------------------------------
Program :1 (working fine)

#!/bin/ksh

for ab in a_DATA.txt b_DATA.txt c_DATA.txt
suf="_"
echo "old->[${ab}] new->[${root}${suf}${_time}]"

old="${ab} "
new=${root}${suf}${_time}

cp $old $new

echo "$_time"
echo "$root"
echo "$new"
done

========================
Program :2 (Not working )

#!/bin/ksh

for ab in *.txt
suf="_"
echo "old->[${ab}] new->[${root}${suf}${_time}]"

old="${ab} "
new=${root}${suf}${_time}

cp $old $new

echo "$_time"
echo "$root"
echo "$new"
done

Thanks in advance !!
  #2 (permalink)  
Old 04-29-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,777
for starters for loops look like this:
Code:
for ........
do
  ........
done
Next, by "not working" - tell us what is the problem? What you gave us cannot possibly work without the "do"
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 07:17 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