building a SET clause in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting building a SET clause in shell script
# 8  
Old 04-10-2007
post the output of:

head -1 /home/z1uals/src/pdsa/mydat/textDMR.txt | tr '\t' ','
# 9  
Old 04-10-2007
Dmr_run_id,rma_server_id,instrument_id,portfolio_id,oas,price
# 10  
Old 04-10-2007
yep because it has no spaces after komma as you wrote in your first post

use:

Code:
#!/usr/bin/ksh
TEXTFILE=/home/z1uals/src/pdsa/mydat/textDMR.txt

for i in $(head -1 $TEXTFILE | tr '\t' ',' | sed 's/,/ /g')
 do
  echo "$i=decode(:$i, '?', $i, :$i),"
 done |  tr [:upper:] [:lower:] | sed '$ s/,$//'

# 11  
Old 04-10-2007
And this is the output of head -1 /home/z1uals/src/pdsa/mydat/textDMR.txt:
DMR_RUN_ID RMA_SERVER_ID INSTRUMENT_ID PORTFOLIO_ID OAS PRICE
# 12  
Old 04-10-2007
Basically the header of the file is tab delimited.
# 13  
Old 04-10-2007
then leave both tr and sed Smilie

Code:
#!/usr/bin/ksh
TEXTFILE=/home/z1uals/src/pdsa/mydat/textDMR.txt

for i in $(head -1 $TEXTFILE)
 do
  echo "$i=decode(:$i, '?', $i, :$i),"
 done |  tr [:upper:] [:lower:] | sed '$ s/,$//'

# 14  
Old 04-10-2007
Thanks much for all help. I am new to shell scripting, could you please point me to a good shell scripting tutorial.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed with shell script to search and replace a set of strings among the set of files

Hi, I am looking for a shell script which serves the below purpose. Please find below the algorithm for the same and any help on this would be highly appreciated. 1)set of strings need to be replaced among set of files(directory may contain different types of files) 2)It should search for... (10 Replies)
Discussion started by: Amulya
10 Replies

2. Shell Programming and Scripting

Generating & executing the SELECT and UPDATE clause dynamically using shell script

Hi All, I need to write one shell script. The requirement is as follows. a) I am having list the employee names in a file stored in /tmp directory location as below /tmp/emp.txt b) and the contents are as below cat emp.txt ravi raj ram arun c) I need to connect to sybase... (1 Reply)
Discussion started by: Gowtham_giri
1 Replies

3. Shell Programming and Scripting

Use a shell variable in where clause

Hi all, I want to use a variable inside my sql query and below is my script: #!/bin/ksh export b="abcd" a=`sqlplus -s abc/def@ghi <<++ set heading off; set feedback off; select xxx from mytable where clmn_nm='$b'; exit; ++` echo $a But the output i get is below: $>... (4 Replies)
Discussion started by: Jayaraman
4 Replies

4. Shell Programming and Scripting

$1 stays set after sourcing shell script.

ok, so I have a shell script that can be called using the first argument ($1) or not. This argument is a word (Tim for example) and not an actual flag (-x for example). If I call the script with an argument and call the same script without one, it believes that I provided an argument. Note here... (2 Replies)
Discussion started by: mrwatkin
2 Replies

5. Shell Programming and Scripting

help with if clause in bash script

hey guys, I am trying to get some statistics from a DHCP server, like counting the number of DHCP Discovers from a specific MAC address. The script should count the number of DHCP Discovers and output it, otherwise if it cannot find any , it should output the MAC address and "0". The first... (10 Replies)
Discussion started by: liviusbr
10 Replies

6. Shell Programming and Scripting

Bash-Shell: If-Clause to check if file is empty

Hello, I want to checkl whether my file has text in it or not. if ; then ... if ; then ... But none of these work Can someone help me? ---------- Post updated at 09:00 AM ---------- Previous update was at 08:55 AM ---------- The code-tags caused an displayerror,... (5 Replies)
Discussion started by: ABE2202
5 Replies

7. Shell Programming and Scripting

How to set PATH using shell script [resolved]

Hi, Can anyone help me on how to set PATH using shell scripting.. Please find the shell script code here.... #!/bin/bash PATH = $PATH:/opt/app/oracle/product/10.2.0/bin export PATH echo $PATH exit When i execute this script i get the following error ./backup.sh: line 2: PATH:... (0 Replies)
Discussion started by: srinivasj
0 Replies

8. Shell Programming and Scripting

How do I set up a shell script using ifconfig?

I am running on AIX 5.3. I have a remote AIX server running on a generator. Many times the generator goes out and I only have a window of 15 mins with the network up and 30 mins the server is powered. I need help creating a script using ifconfig, where it goes out and checks the network every 5... (2 Replies)
Discussion started by: AIX25
2 Replies

9. Shell Programming and Scripting

set password using a shell script

Hi All How can I set password in linux.It is OK if it display password in plain text in script. manually i can set: #passwd Changing password for root Enter new password: Bad password: too weak. Re-enter new password: Password changed. # I want this to be done by script.Please let me... (2 Replies)
Discussion started by: tannu
2 Replies
Login or Register to Ask a Question