| | |
OMG... simple question driving me nuts
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2009
Posts: 5
Reputation:
Solved Threads: 0
Hey guys,
Just trying to do a simple shell script to generate a query line... can someone tell me why this does not work?
if you take out the $ before each of the e's, I get exactly what I am looking for... except of course there is an e where I want the variable to be.
Just trying to do a simple shell script to generate a query line... can someone tell me why this does not work?
Shell Scripting Syntax (Toggle Plain Text)
for e in `cat file.txt`; do echo INSERT INTO \`omstest_omstest\`.\`GEN2_FIELD\` VALUES \(NULL, \'$e\', \'$e\', \'4\', \'2009-10-05 00:00:00\', \'0\' \'0\'\)\;; done;
if you take out the $ before each of the e's, I get exactly what I am looking for... except of course there is an e where I want the variable to be.
0
#3 Nov 7th, 2009
What shell are you using, and what error are you receiving?
It seems to work for me:
Some shells do not like to evaluate $vars unless they are in a
It seems to work for me:
Shell Scripting Syntax (Toggle Plain Text)
sk@svn:/tmp$ for e in `cat file.txt`; do echo INSERT INTO \`omstest_omstest\`.\`GEN2_FIELD\` VALUES \(NULL, \'$e\', \'$e\', \'4\', \'2009-10-05 00:00:00\', \'0\' \'0\'\)\;; done; INSERT INTO `omstest_omstest`.`GEN2_FIELD` VALUES (NULL, 'ABC', 'ABC', '4', '2009-10-05 00:00:00', '0' '0');
Some shells do not like to evaluate $vars unless they are in a
" , not a single ' . •
•
Join Date: Nov 2009
Posts: 5
Reputation:
Solved Threads: 0
0
#4 Nov 9th, 2009
I'm using bash... No errors... but the moment I put a $var in place of the two e's, my output gets all jumbled up... and only the last line of the file prints correctly... it is almost like it is reading a new line that is not there... or at least that I am not seeing.
What shell did you use? Did you try it with more than one line in the test file?
What shell did you use? Did you try it with more than one line in the test file?
0
#6 Nov 10th, 2009
I'm glad you got it working 
Please mark this thread as solve as you have found your solution to the issue and good luck!

Please mark this thread as solve as you have found your solution to the issue and good luck!
![]() |
Similar Threads
- simple question about servlet (JSP)
- simple question (Python)
- help! simple question (Python)
- HI/ I have a simple question (Domains and DNS)
- Report Server Problem (MS SQL)
- A simple question about Ram (Motherboards, CPUs and RAM)
- simple question (C++)
- This has to be a simple question to answer. (Visual Basic 4 / 5 / 6)
- Serialize/MFC Question (C)
- Mac Mouse Problem! Help me out? (OS X)
Other Threads in the Shell Scripting Forum
- Previous Thread: file replacement not working!
- Next Thread: Help with grep?
Views: 717 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Shell Scripting







