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
Appending 'string' to file as first column. satyam_sat Shell Programming and Scripting 6 02-20-2009 05:15 AM
Appending a string to all files in a directory ragavhere Shell Programming and Scripting 1 04-28-2008 06:31 AM
Sed appending string using for loop? cstovall Shell Programming and Scripting 2 01-28-2007 09:30 PM
appending string to text file based on search string malaymaru Shell Programming and Scripting 1 06-09-2006 08:53 AM
Appending to filename a string of text grep finds HLee1981 Shell Programming and Scripting 3 09-06-2005 02:44 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-19-2008
krishna9 krishna9 is offline
Registered User
  
 

Join Date: May 2008
Posts: 9
Arrow appending two string is not working

Dear Memebers

appending string is not working in loop
outside of loop itw working fine, but when i put in loop its not working.
please look into this code and suggest me how to do this.

supplierCode.txt
---------------
UGEN
SLAND
CEL

here is my script
-------------------

#!/bin/bash
SuppFile=/home/krishnaveni/scripts/supplierCode.txt
file1=log
filename=$file1".txt"
#echo $filename # its working fine
exec 0<$SuppFile
while read LINE
do
echo $LINE
suppProfileName=$LINE"_sftp.profile"
echo $suppProfileName

done

----------------------
Here output is
UGEN
_sftp.profile
SLAND
_sftp.profile
CEL
_sftp.profile


-----------------
but i want output like

UGEN_sftp.profile
SLNAD_sftp.profile
CEL_sftp.profile


Please help me on this.

thanks
krishna.
  #2 (permalink)  
Old 05-19-2008
aju_kup aju_kup is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 189
try like this

Code:
filename=${file1}".txt"
Code:
suppProfileName=${LINE}"_sftp.profile"
  #3 (permalink)  
Old 05-19-2008
krishna9 krishna9 is offline
Registered User
  
 

Join Date: May 2008
Posts: 9
Its not working
still output is like this

UGEN
_sftp.profile
SLAND
_sftp.profile
CEL
_sftp.profile


inside of this loop is not working.
  #4 (permalink)  
Old 05-19-2008
elthox elthox is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 30
Quote:
Originally Posted by krishna9 View Post
Dear Memebers

appending string is not working in loop
outside of loop itw working fine, but when i put in loop its not working.
please look into this code and suggest me how to do this.

supplierCode.txt
---------------
UGEN
SLAND
CEL

here is my script
-------------------

#!/bin/bash
SuppFile=/home/krishnaveni/scripts/supplierCode.txt
file1=log
filename=$file1".txt"
#echo $filename # its working fine
exec 0<$SuppFile
while read LINE
do
echo $LINE
suppProfileName=$LINE"_sftp.profile"
echo $suppProfileName

done

----------------------
Here output is
UGEN
_sftp.profile
SLAND
_sftp.profile
CEL
_sftp.profile


-----------------
but i want output like

UGEN_sftp.profile
SLNAD_sftp.profile
CEL_sftp.profile


Please help me on this.

thanks
krishna.


Check it like this:

while read LINE
do
suppProfileName=`echo $LINE"_sftp.profile"`
echo $suppProfileName

done
  #5 (permalink)  
Old 05-19-2008
krishna9 krishna9 is offline
Registered User
  
 

Join Date: May 2008
Posts: 9
i dont know why its not working
i tried with commands which you provided me
still its giving output

_sftp.profile
_sftp.profile
_sftp.profile

i tried with
suppProfileName=`echo $LINE"_sftp.profile"`
echo $suppProfileName
and
suppProfileName=`echo ${LINE}"_sftp.profile"`
echo $suppProfileName
no use what to do now, can i know is there any problem with my script.
  #6 (permalink)  
Old 05-19-2008
penchal_boddu penchal_boddu is offline
Registered User
  
 

Join Date: Apr 2008
Location: Bangalore
Posts: 127
hi krishna,

can u send the output of following command.

cat -v supplierCode.txt

May be bcoz some non-printable characters at the end ( Just guessing )

Thanks
Penchal
  #7 (permalink)  
Old 05-19-2008
penchal_boddu penchal_boddu is offline
Registered User
  
 

Join Date: Apr 2008
Location: Bangalore
Posts: 127
Try

suppProfileName=${LINE}_sftp.profile
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 05:51 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