how to read a file to an echo statement


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to read a file to an echo statement
# 1  
Old 03-24-2009
how to read a file to an echo statement

I was searching for an option where i can echo some strings together with the contents of a file.

Eg. I was to echo the below string to a file
"alter application PMS_ add variable CurrYear Y2009;" >> ${ESS_MAXL_DIR}/PMS_SUB.txt

The value 2009 is coming from a file called date.txt without the Y, so i'm looking for an option to get Y2009 to my echo statement.

Can somebody please help me with this?

Regards

CK
# 2  
Old 03-24-2009
Quote:
Originally Posted by Celvin VK
I was searching for an option where i can echo some strings together with the contents of a file.

Eg. I was to echo the below string to a file
"alter application PMS_ add variable CurrYear Y2009;" >> ${ESS_MAXL_DIR}/PMS_SUB.txt

The value 2009 is coming from a file called date.txt without the Y, so i'm looking for an option to get Y2009 to my echo statement.

Can somebody please help me with this?

Regards

CK
you mean like this???
Code:
fnsonlu1-/home/fnsonlu1> cat vv
2009
fnsonlu1-/home/fnsonlu1> echo "Y"`cat vv`
Y2009

# 3  
Old 03-24-2009
Quote:
Originally Posted by vidyadhar85
you mean like this???
Code:
fnsonlu1-/home/fnsonlu1> cat vv
2009
fnsonlu1-/home/fnsonlu1> echo "Y"`cat vv`
Y2009

Thanks a lot Vidya this is the one!!!!!!SmilieSmilie
# 4  
Old 03-24-2009
few more ways!!!
Code:
fnsonlu1-/home/fnsonlu1> printf "Y"`cat vv`"\n"
Y2009
fnsonlu1-/home/fnsonlu1> sed 's/\(.*\)/Y\1/g' vv
Y2009
fnsonlu1-/home/fnsonlu1> awk '{print "Y"$0}' vv
Y2009

This User Gave Thanks to vidyadhar85 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If echo statement return false

I have this code that sometimes return a false value and the code inside the if statement gets executed and error out. Any idea why? thanks. So I set a debug and see what the value for $ScriptElapsedTime Here is the value I got ScriptElapsedTime='03:20'. Base on this value the if... (10 Replies)
Discussion started by: nugent
10 Replies

2. Shell Programming and Scripting

Shell script to read specified value from file and echo to the same location to other file.

Hello. I want to to backup some "default:" values from a file do some other job and after restore that "default:" values back. The problem is that the source and destination file has a lot of default: strings in it but with different values... So.. Here is an example: A part of my source... (6 Replies)
Discussion started by: ausdim
6 Replies

3. Shell Programming and Scripting

How to read each line from input file, assign variables, and echo to output file?

I've got a file that looks like this (spaces before first entries intentional): 12345650-000005000GL140227 ANNUAL HELC FEE EN 22345650-000005000GL140227 ANNUAL HELC FEE EN 32345650-000005000GL140227 ANNUAL HELC FEE EN I want to read through the file line by line,... (6 Replies)
Discussion started by: Scottie1954
6 Replies

4. Shell Programming and Scripting

echo ls to a file and then read file and selectively delete

I'm trying to write a script that will do an ls of a location, echo it into a file, and then read that file and selectively delete files/folders, so it would go something like this: cd $CLEAN_LOCN ls >>$TMP_FILE while read LINE do if LINE = $DONTDELETE skip elseif LINE =... (2 Replies)
Discussion started by: MaureenT
2 Replies

5. UNIX for Dummies Questions & Answers

echo appends to a read-only file

echo command can append to a read-only file too. If the file is read-only, with w flag removed, then even echo should not be able to append to the file. But it is possible. Can anybody explain the below behaviour? /root > echo 'sample text' > file /root > cat file sample text /root >... (2 Replies)
Discussion started by: anand_bh
2 Replies

6. Shell Programming and Scripting

Output of both the echo statement in one line

I have script like echo -n FINISHED FEXP: ${TABLE2EXP} echo $STATUS I want the output of both the echo statement in one line How can i do this (3 Replies)
Discussion started by: scorp_rahul23
3 Replies

7. Shell Programming and Scripting

setting width in echo statement

Hello All, I need to set the width or number of columns for my dynamic output in the echo statement. statement is like: echo " <output> " here the <output> is dyamice and can be of any number of characters, the " " should always start in same column everytime it is... (4 Replies)
Discussion started by: s123.radha
4 Replies

8. Shell Programming and Scripting

echo statement issue

Hi All, I am pasting my code below if # e means file exists then echo OFR_Configlist exists >> OFR_Backup_Configfiles.log else echo OFR_Configlist Not exists >> OFR_Backup_Configfiles.log exit fi How can i show the echo message in console also at the same time? I dont want to write... (3 Replies)
Discussion started by: subin_bala
3 Replies

9. Shell Programming and Scripting

Insert TAB in echo statement

Hi, Can some1 help me to output a tab in an echo statement. I have tried echo "RNC: \t NODEB" but dont get the correct output. I am a beginnger to unix, so pls hold back the laughs....if u can (5 Replies)
Discussion started by: sunils27
5 Replies

10. Shell Programming and Scripting

echo statement

Does anyone know the correct syntax for computing arithmetic expressions inside the echo statement? Let me know, thanks (3 Replies)
Discussion started by: circleW
3 Replies
Login or Register to Ask a Question