extracting parameter from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting extracting parameter from file
# 1  
Old 09-04-2008
extracting parameter from file

Hi
I have file

128 BES-Exchange [perf08:storage1] BES-Exchange/BES-Exchange.vmx winNetEnterpriseGuest vmx-04
144 BES-SVR [perf08:storage1] BES-SVR/BES-SVR.vmx winNetEnterpriseGuest vmx-04
176 BES AD [perf08:storage1] BES-AD/BES AD.vmx winNetEnterpriseGuest vmx-04


so in above file i want to extract only BES AD
the BES AD is seperated by tab i tried with gawk but not getting exact what i want
I want following output

BES-Exchange
BES-SVR
BES AD

Thanks
Brahma
# 2  
Old 09-04-2008
awk -F"[" '{print $1}' infile|cut -d' ' -f1 something like this
or instead of cut you can use sed also...
awk -F"[" '{print $1}'|sed -e 's/^ *[^ ]* //'
# 3  
Old 09-04-2008
cat File.txt
128 BES-Exchange [perf08:storage1] BES-Exchange/BES-Exchange.vmx winNetEnterpriseGuest vmx-04
144 BES-SVR [perf08:storage1] BES-SVR/BES-SVR.vmx winNetEnterpriseGuest vmx-04
176 BES AD [perf08:storage1] BES-AD/BES AD.vmx winNetEnterpriseGuest vmx-04

awk -F"/|[.]" '{print $2}' File.txt
# 4  
Old 09-04-2008
when i do this it gives me output as


128 BES-Exchange

144 BES-SVR
176 BES AD

i want only BES and things
# 5  
Old 09-04-2008
Quote:
Originally Posted by bp_vardhaman
when i do this it gives me output as


128 BES-Exchange

144 BES-SVR
176 BES AD

i want only BES and things
the pipe it to cut or sed to remove first word as i suggested..
# 6  
Old 09-04-2008
bp_vardhaman,

du tried awk -F"/|[.]" '{print $2}' File.txt this ?
# 7  
Old 09-04-2008
But i even want tab also but here its coming as without tab Smilie

BES AD
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Multiple file and single parameter file

Hi Team, In our project we have written below 2 scripts like Script1: Shell script start & END Begin Audit process - uses teradata bteq END Audit Process Script 2: Environemtal variable file different Now Client ask to change this requirement and need below files: Script1:... (1 Reply)
Discussion started by: tusharzaware1
1 Replies

2. Shell Programming and Scripting

Call Script with Parameter (that has another parameter)

Hi. How do I achieve this sh /EDWH-DMT02/script/MISC/exec_sql.sh "@/EDWH-DMT02/script/others/CSM_CKC/Complete_List.sql ${file_name}" Complete_List.txt The /EDWH-DMT02/script/MISC/exec_sql.sh has two parameters and it's working fine with this sh /EDWH-DMT02/script/MISC/exec_sql.sh... (7 Replies)
Discussion started by: aimy
7 Replies

3. Shell Programming and Scripting

How to get the parameter value from the parameter file in perl?

hi all, i have a parameter file of following format, i want a method which can get the value of specific parameter. parameter file format: <Parameter Name="FileLocationWindows"> <Description> The directory location of the logger file. ... (1 Reply)
Discussion started by: laxmikant.hcl
1 Replies

4. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

5. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

6. Shell Programming and Scripting

Extracting unknown positional parameter in Bourne shell

I have a variable that contains the number of a positional parameter. There is no way of knowing what number this may be, although it is guaranteed to correspond with a valid parameter. In BASH I could just use ${@} to extract that argument. But in a Bourne shell the best I can come up with is... (3 Replies)
Discussion started by: mij
3 Replies

7. UNIX for Dummies Questions & Answers

Reading from a file(passing the file as input parameter)

hi I have a shell script say primary.sh . There is a file called params my scenario is primary.sh should read all the values and echo it for example i should pass like $primary.sh params output would be Abc ... (2 Replies)
Discussion started by: ssuresh1999
2 Replies

8. Shell Programming and Scripting

Getting the value from a parameter file

Hi I am nebie to Unix I have a prameter file which has semicolon seperated values which has the field STATUS_CODE;9000;1;1200;2000 The values are dynamic ie. it can be 1,2,3...any number How do i get all the values of this parameter into a variable Please if anyone can help me out on... (2 Replies)
Discussion started by: theeights
2 Replies

9. Shell Programming and Scripting

Extracting data from text file based on configuration set in config file

Hi , a:) i have configuration file with pattren <Range start no>,<Range end no>,<type of records to be extracted from the data file>,<name of the file to store output> eg: myfile.confg 9899000000,9899999999,DATA,b.dat 9899000000,9899999999,SMS,a.dat b:) Stucture of my data file is... (3 Replies)
Discussion started by: suparnbector
3 Replies

10. Shell Programming and Scripting

how do I make dynamic parameter names? Or get the value of a parameter evaluated twi

Say I write something like the following: var1=1 var2=2 for int in 1 2 do echo "\$var$int" done I want the output to be: 1 2 Instead I get something like: $var1 $var2 (2 Replies)
Discussion started by: Awanka
2 Replies
Login or Register to Ask a Question