The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
create PATH from find command output rein UNIX for Dummies Questions & Answers 3 04-01-2008 07:35 AM
trying to create a script with multiple variables... Italy87 UNIX Desktop for Dummies Questions & Answers 5 03-21-2008 02:09 PM
parse multiple lines? should be a easy answer... DeuceLee UNIX for Dummies Questions & Answers 4 01-04-2008 04:54 PM
Create Variable for a PATH mmignot Shell Programming and Scripting 2 11-06-2006 03:09 PM
Create Folder in Multiple Directories Stud33 Shell Programming and Scripting 15 07-20-2006 03:44 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-02-2008
shirleyeow shirleyeow is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 19
Parse value from multiple row to create the path

Hi all,

Hope all the expert can help me in this situation.

Let say I have one file with multiple record like below:

[10001]
NAME=FRAGMENT
LANGUAGE=1
DIALECT=0
GENDER=NONE
FILE=TEST1
DIRECTORY=D:/DETAILS/1/0/test1.txt
END

[10002]
NAME=FRAGMENT
LANGUAGE=1
DIALECT=0
GENDER=NONE
FILE=TEST2
DIRECTORY=
END

[10003]
NAME=FRAGMENT
LANGUAGE=1
DIALECT=0
GENDER=NONE
FILE=TEST3
DIRECTORY=
END

For each record, I need to generate the path for DIRECTORY where,

- D:/DETAILS/ is fixed
- 1 is taken from LANGUAGE=1
- 0 is taken from DIALECT=0
- test1 is taken from FILE=TEST1
- test1 must be SMALL LETTER

Since in the file there are huge amount of records,so I think may be can use script to generate the path for each record. But getting stuck for the script now. Please advise.

Thank you so much.

Best Regards,
Shirley
  #2 (permalink)  
Old 05-02-2008
rikxik's Avatar
rikxik rikxik is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 250
Show what script have you prepared so far.
  #3 (permalink)  
Old 05-02-2008
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 393
Try:
Code:
awk ' /DIRECTORY/ {print $1"=D:/DETAILS/"a["LANGUAGE"]"/"a["DIALECT"]"/"tolower(a["FILE"]);next}a[$1]=$2{}1' FS='=' sourceFile
  #4 (permalink)  
Old 05-02-2008
shirleyeow shirleyeow is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 19
Error while execute the command

Hi Klashxx,

I get the below error when execute the command:

awk: syntax error near line 1
awk: bailing out near line 1

Try to solved it many times already but still getting the same error. Please advise.

Thank you.

Best Regards,
Shirley
  #5 (permalink)  
Old 05-02-2008
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 393
Solaris box??
  #6 (permalink)  
Old 05-02-2008
DILEEP410 DILEEP410 is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 148
Quote:
Originally Posted by shirleyeow View Post
Hi Klashxx,

I get the below error when execute the command:

awk: syntax error near line 1
awk: bailing out near line 1

Try to solved it many times already but still getting the same error. Please advise.

Thank you.

Best Regards,
Shirley
Try out this !

nawk -F"=" '/DIRECTORY/ {print $1"=D:/DETAILS/"a["LANGUAGE"]"/"a["DIALECT"]"/"tolower(a["FILE"]);next}a[$1]=$2{}1' file.txt
  #7 (permalink)  
Old 05-02-2008
shirleyeow shirleyeow is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 19
Error while execute the command

Hi Klashxx,

Yup, is Solaris box.

Hi DILEEP410,

The command is ok but it didnt return the path that I want, the LANGUAGE, DIALECT and FILE value are missing. Please advise.

RESULT:
[10001]
NAME=FRAGMENT
LANGUAGE=1
DIALECT=0
GENDER=NONE
FILE=TEST1
DIRECTORY=D:/DETAILS///
END


Thank you.

Best Regards,
Shirley
Closed Thread

Bookmarks

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0