Create an execution logic of script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create an execution logic of script
# 1  
Old 02-09-2014
Create an execution logic of script

Hi All,

I have a file which is in below shape. Script should run and pick 1 and 2nd line and first line value store in A variable only numeric and 2nd line value should store in B variable only numeric. Then I have command which will check the value of these two tickets if both is having the same Checkpoint label then next command will make the relationship between both if not then skip and script will pick next two lines i.e 3rd and 4th.If the value of any variable is null then script will exit.

Please let me know how could I store the first line value in variable A and second line value in variable B then do it for all.

Please suggest

File name is Test(Format):example

Code:
PreProduction 123456
Production 345678
PreProduction 123456
Production 345678
PreProduction 123456
Production 345678
PreProduction 123456
Production 345678
PreProduction 123456
Production 345678
PreProduction 123456
Production 345678

Thanks-

Last edited by Scrutinizer; 02-09-2014 at 04:11 AM.. Reason: add some more lines. [mod] removed formatting, added code tags
# 2  
Old 02-09-2014
Try:
Code:
while read A && read B
do 
  printf "This is \$A: %s\n" "$A"
  printf "This is \$B: %s\n" "$B"
done < file

But maybe you mean this:
Code:
while read _ A _ && read _ B _
do 
  printf "This is the second value on the line, \$A: %s\n" "$A"
  printf "This is the second value on the line, \$B: %s\n" "$B"
done < file

The underscore is used to capture and discard the first field and a potential last field after the second field (if ever there should be one)

Last edited by Scrutinizer; 02-09-2014 at 04:30 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execution problems with the jar -tvf command and "if" logic

Hi, I am reading a directory that has a list of jar files. I am searching these files for specific keywords. What i would like to do is write the address of the jar file to a new file if the search result is returned as false. For example; /home/user/JarDirectory/Examplefile.jar ... (2 Replies)
Discussion started by: crunchie
2 Replies

2. Shell Programming and Scripting

How to create file execution in KSH shell

Dear all, I'm new in Unix system, I need help about how to create execution file. for example in my system i have file fg* when i open fg file i get : cmd='basename$0' $cmd "$@" how to create file like that (execution file) in KSH shell thank you for your help heru (4 Replies)
Discussion started by: heru_90
4 Replies

3. UNIX for Dummies Questions & Answers

create a periodic execution of a script?

Hello every body goal: create a script that control periodicly ( every 30 min ) if a process is already actif. How can I do that? thanks (3 Replies)
Discussion started by: hoang
3 Replies
Login or Register to Ask a Question