Help needed in UNIX scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed in UNIX scripting
# 1  
Old 11-22-2013
Help needed in UNIX scripting

Hi,

I have 2 variables which is having like the below data
Code:
a=x.1 y.2 z.3 m.4
b=No (zero) rows read (0)~ No (zero) rows read (0)~ Complete: 273894 row(s)~ Complete: 729002 row(s)~

I need a file which should contain
Code:
x.1,No (zero) rows read (0)~ 
y.2,No (zero) rows read (0)~ 
z.3,Complete: 273894 row(s)~ 
m.4,Complete: 729002 row(s)~


Last edited by Ravindra Swan; 11-22-2013 at 08:15 AM.. Reason: small change
# 2  
Old 11-22-2013
Try this. I'm sure you can cope yourself with the leading blanks in BR[]...
Code:
AR=($a)
IFS="~" BR=($b)
for ((i=0; i<${#AR[@]}; i++)); do printf "%s,%s~\n" ${AR[$i]} ${BR[$i]}; done
x.1,No (zero) rows read (0) ~
y.2, No (zero) rows read (0) ~
z.3, Complete: 273894 row(s) ~
m.4, Complete: 729002 row(s) ~


Last edited by RudiC; 11-22-2013 at 08:39 AM.. Reason: forgot two important lines ... sorry
# 3  
Old 11-22-2013
Code:
set -- $a
i=1;
while [ $i -le $# ]
do
eval echo -n \$$i
echo $b | awk -F"~" -v var=$i '{ print ","$var}'
i=`expr $i +  1`
done

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX shell scripting - help needed

Can anyone please help me to create the output file based on the attached input files using ksh script. I have 2 input files 1) inputfile1.txt 2) inputfile2.txt The script should accept 2 parametes: 1. Inputfile2.txt with 1-10,000 values ( sample file contains only 4 records) 2. Script... (5 Replies)
Discussion started by: vinus
5 Replies

2. Shell Programming and Scripting

Scripting Help needed

Hi folks, need a small help lets say i have a text file with the following content: james tom jack spielberg i want to append text to the beginning of each line with a variable(lets says FirName:) and i want to combine all the names with a space in between and store it in another... (11 Replies)
Discussion started by: tech_frk
11 Replies

3. Shell Programming and Scripting

Help needed in scripting

Hi Guys, I need help in scripting out the below : this is a sample data i have in my file: jobname type 8:00:00 AM I need to remove the ":00" from the time field alone. Thanks in advance for all ur help (8 Replies)
Discussion started by: a12ka4
8 Replies

4. Shell Programming and Scripting

Scripting help needed

Hi All, I have a conf file and it has two entries seperated by comma, look like :- best1,ls /opt/bmc/Patrol3/*/best1 ......, ....................... In which "Best1" is the product name and "ls /opt/bmc/Patrol3/*/best1" is the way to find the product version of Best1 in that particular... (5 Replies)
Discussion started by: Renjesh
5 Replies

5. Homework & Coursework Questions

Scripting needed

Hi, My task is to check the file test.txt every 15 min from Mon-Fri 9:00AM - 6:00PM. We get this file from our mainframes, every 15 min it will update the same file. My task is to compare file timestamp with current system time stamp and check if the file is updated or not. If the file doesn't... (0 Replies)
Discussion started by: chinniforu2003
0 Replies

6. Shell Programming and Scripting

Help needed with scripting.

Hello Friends, I am very new to scripting and currently have come across a situation where I need to create a UNIX script which would look for certain text in a file and then email me if it finds it. I am trying to trouble shoot an issue with our internet websites and I need to know when I... (1 Reply)
Discussion started by: mahive
1 Replies

7. UNIX for Dummies Questions & Answers

sh scripting! Help Needed

Hello fellas or ladies. I am new on this site and new to the unix operating system. I have been working with UNIX and i love it so far, i learned some stuff and most of the beneficiary command but I need help renaming all the files in my directory and doing them one by one is just tiring. is there... (3 Replies)
Discussion started by: keyboardkowboy
3 Replies

8. Shell Programming and Scripting

sh scripting! Help Needed

Hello fellas or ladies. I am new on this site and new to the unix operating system. I have been working with UNIX and i love it so far, i learned some stuff and most of the beneficiary command but I need help renaming all the files in my directory and doing them one by one is just tiring.... (1 Reply)
Discussion started by: keyboardkowboy
1 Replies

9. Shell Programming and Scripting

little scripting help needed!!

guys i need bit of help!! i am writing a script which finds files that have not been accessed for a no of days and delete those files...the no of days value is inputted at the command line.... i am using the following : find $1 -atime +7 -exec rm -i in the second step i want to copy all... (2 Replies)
Discussion started by: vats
2 Replies
Login or Register to Ask a Question