Problem getting the content of a file in a shell script variable
Hi,
I have a text file that has a long multi-line db2 CTE query. Now I want to store all the contents of this file (i.e. the entire query) in a shell script variable. I am trying to achieve it by this:
But when I echo the contents of this file by saying
then the resultant output is a mess. The output includes the text from the file /Folder/SomeFile.txt and the filenames of other files which are located in the folder where the shell script file is stored, mixed with each other. I want to use this query to pass it to a db2 stored procedure. Please help.
Thank u for replying. But I need to call the stored procedure by
Now I cannot call it like
So quoting wont help. I understand that quoting the variable helps when we want to echo it but it doesnt help in my case when I'm trying to use it in some other statement. I tried using
but it doesnt work.
Other strange thing is that when I do
Still the output shows all the other file names in the folder where this script is saved. And when I quote it ("$var") then it doesnt show those other filenames in the output but gives these extra [ [ [ [ [ brackets which are not at all there in the file.
And the problem still remains that I cant quote this var in the call to the stored proc.
Plz suggest me what to do.
Thanks for replying. I now get it why I had those extra brackets [[ ( lol ). Even though I can see proper contents of the file on echoing the the variable within quotes. But when I pass this variable to another script, in that other script the variable is expanded as the contents of that file plus some extraaaaa file and subfolder names which are stored along with the first script that has passed this variable. I just cant seem to understand why this is happening.
Say my file contains text:
abc
efg
hijklm
And the script file is stored along with other files like a.txt, b.txt and folders fol1, fol2, fol3 etc.
I call this other script p.sh with the argument -x
ie.
But when I see the results poduced by p.sh it contains:
abc
efg a.txt b.txt fol1 fol2
hijklm fol3
I am new to shell scripting. I am interested how to know how to sort a content of a file using shell scripting.
I've attached the 'Input file' and the 'expected output' to this thread.
Details provided in the expected output file will provide details on how the sort needs to be done.
... (16 Replies)
Hi Guru's,
I am new to shell scripting. I have a unique requirement:
The system generates a single pdf(/tmp/ABC.pdf) file with Invoices for Multiple Customers, the format is something like this:
Page1 >> Customer 1 >>Invoice1 + invoice 2 >> Page1 end
Page2 >> Customer 2 >>Invoice 3 + Invoice 4... (3 Replies)
Hi
I am looking for a help in designing a bash script on linux which can do below:-
1) Look in a specific directory for any new files
2) Mail the content of the new file
Appreciate any help
Regards
Neha (5 Replies)
HI All..
below is my menu options script. in option 2,3 and 4 im giving input and they are saving into their respective text file.
problem is when im trying to "cat" those files in options 7,8 and 9 im not getting the output. no respective file contents are displaying on screen. but if i... (1 Reply)
Hello,
I need to do one thing that my script creates the file
touch release.SPLASH_12_03_00_RC01.txt
Now I want to update that file with some content e.g
splashbuild::SPLASH_12_17_00_RC02.zip
Thanks (1 Reply)
Hi Guys,
I have a file. Each record needs to inserted into a table. The table also have other columns which needs to be inserted with Shell variables.
The following is the file.
Error code None.
Error Code 1
The shell script is having these variables.
Name=Magesh
Dep=Coding
... (1 Reply)
How can I remove all data that contain domain e.g zzgh@something.com, sdd@something.com.my and gg@something.my in one file? so that i only have data without the domain in the file.
Here is the file structure "test.out"
more test.out
1 zzztop@b.com
1 zzzulll
1 zzzullll@s.com.my
... (4 Replies)
when I write the kourne shell script on a solaris machaine like this:
#!/bin/ksh
myps =50
echo $myps
and when I run this script with typing "myfile"
, it shows this message:
myfile: myps: not found
I think I write a correct syntax but why a program show error like that. (3 Replies)
Hi
I have one properties file containing as
$INSTALL_BASEPATH/mssages/commonmessages_default.properties
$INSTALL_BASEPATH/resource/configurationBundle.properties
and $INSTALL_BASEPATH is set in .bash_profile
but from shell script when I read this file
and use in copy statement then it... (7 Replies)
Hi
I need some help using shell script to edit a file.
My original file has the following format:
/txt/email/myemail.txt
/txt/email/myemail2.txt
/pdf/email/myemail.pdf
/pdf/email/myemail2.pdf
/doc/email/myemail.doc
/doc/email/myemail2.doc
I need to read each line. If the path is... (3 Replies)