appending two string is not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting appending two string is not working
# 1  
Old 05-19-2008
CPU & Memory 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  
Old 05-19-2008
try like this

Code:
filename=${file1}".txt"

Code:
suppProfileName=${LINE}"_sftp.profile"

# 3  
Old 05-19-2008
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  
Old 05-19-2008
Quote:
Originally Posted by krishna9
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  
Old 05-19-2008
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  
Old 05-19-2008
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  
Old 05-19-2008
Try

suppProfileName=${LINE}_sftp.profile
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check file for string existence before appending it with string

I want to append file with a string but before doing that i want to check if this string already exist in that file.I tried with grep on Solaris 10 but unsuccessful.Man pages from grep seems to suggest if the string is found command status will be 0 and if not 1.But i am not finding it.May be i... (2 Replies)
Discussion started by: sahil_shine
2 Replies

2. Shell Programming and Scripting

Trouble appending string constant to variable

Hi. I define my variables as: month=jul DD=17 YEAR=2012 transmission_file_name_only=test_$month$DD$YEAR_partial.dat However when I run my script the variable 'transmission_file_name_only' resolves to: File "/downloads/test_jul17.dat" not found. How can I append this '_partial'... (3 Replies)
Discussion started by: buechler66
3 Replies

3. Shell Programming and Scripting

searching the required string and appending string to it.

Hi all, I have some data in the form of adc|nvhs|nahssn|njadnk|nkfds in the above data i need to write a script so thet it will append "|||" to the third occurnace in the string ..... the outout should look like adc|nvhs|nahssn||||njadnk|nkfds Thanks, Firestar. (6 Replies)
Discussion started by: firestar
6 Replies

4. Shell Programming and Scripting

Appending string, variable to file at the start and string at end

Hi , I have below file with 13 columns. I need 2-13 columns seperated by comma and I want to append each row with a string "INSERT INTO xxx" in the begining as 1st column and then a variable "$node" and then $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13 and at the end another string " ; COMMIT;" ... (4 Replies)
Discussion started by: Vaddadi
4 Replies

5. Shell Programming and Scripting

Appending string at the end of the file

Hello, I wanted to append 'XYZ' at the end of the text file. How can i do this? I searched the forums and i am not getting what i want. Any help is highly appreciated. Thanks (2 Replies)
Discussion started by: govindts
2 Replies

6. Shell Programming and Scripting

Need help appending a string to a field

Hi, This is driving me nuts, can't think of any easy way to do it. I need to append a string ".00" only in the third field of a file, and only if it does NOT have a decimal point already Here is what the file looks like- 1400030846,2,17,POL GENERAL 1400030900,3,14.95,FIC GENERAL If... (7 Replies)
Discussion started by: sfisk
7 Replies

7. Shell Programming and Scripting

Appending 'string' to file as first column.

Hi , I have the below file with 6 columns.I want to append 'File1' as the 1 column to the file. i have the sample code .It is not working . can u please correct this or make new one ..... awk 'print {'File1',$1,$2,$3,$4,$5,$6}' Source_File> Result_File Source_File:... (6 Replies)
Discussion started by: satyam_sat
6 Replies

8. Shell Programming and Scripting

Appending a string to all files in a directory

Hi, I will have to append a common string at the beginning of each and every line to all files in the same directory. How do i do this? (1 Reply)
Discussion started by: ragavhere
1 Replies

9. Shell Programming and Scripting

Sed appending string using for loop?

Hi All, I have been trying to format a file using sed. I can't seem to get the syntax right. I want to append the string from file1.txt to file1.csv with the final output file being file2.csv, but before the string is appended to the end of each line, first insert a comma. Here is the sed... (2 Replies)
Discussion started by: cstovall
2 Replies

10. Shell Programming and Scripting

appending string to text file based on search string

Hi, I need to append string "Hi" to the beginning of the lines containing some specific string. How can I achieve that? Please help. Malay (1 Reply)
Discussion started by: malaymaru
1 Replies
Login or Register to Ask a Question