Sponsored Content
Top Forums Shell Programming and Scripting Need an advanced version of this script Post 302439506 by rdcwayx on Thursday 22nd of July 2010 09:49:06 PM
Old 07-22-2010
find a lazy way, which you can adjust your template xml easily in the future.

Create a template first:

Code:
$ cat template
<label>
  <Spalte_1>Datensatz 1 Spalte 1</Spalte_1>
  <Spalte_2>Datensatz 1 Spalte 2</Spalte_2>
  <Spalte_3>Datensatz 1 Spalte 3</Spalte_3>
  <Spalte_4>Datensatz 1 Spalte 4</Spalte_4>
        <sublabel>
          <Employee>Tommy Foo</Employee>
          <Date>14.05.2010</Date>
          <Time>30 Min</Time>
        </sublabel>
</label>

Set the input file:

Code:
$ cat input
'Spalte_1'      'Spalte_2'      'Spalte_3'      'Spalte_4'      'Employee'      'Date'  'Time'
Datensatz 1 Spalte 1    Datensatz 1 Spalte 2    Datensatz 1 Spalte 3    Datensatz 1 Spalte 4    Tommy Foo       14.05.2010      30 Min
Datensatz 2 Spalte 1    Datensatz 2 Spalte 2    Datensatz 2 Spalte 3    Datensatz 2 Spalte 4    Steve Lee       15.05.2010      45 Min
Datensatz 3 Spalte 1    Datensatz 3 Spalte 2    Datensatz 3 Spalte 3    Datensatz 3 Spalte 4    Joe Average     15.05.2010      90 Min
Datensatz 4 Spalte 1    Datensatz 4 Spalte 2    Datensatz 4 Spalte 3    Datensatz 4 Spalte 4    Jimmy Choo      16.05.2010      80 Min
Datensatz 5 Spalte 1    Datensatz 5 Spalte 2    Datensatz 5 Spalte 3    Datensatz 5 Spalte 4    Mary Haha       18.05.2010      130 Min

Then run below command:

Code:
awk -F "\t" 'NR==FNR {a[++i]=$0; next}
             FNR>1 {print a[1]
             for (j=1;j<=4;j++) {gsub(/>.*</,">"$(j)"<",a[j+1]); print a[j+1]}
             print a[6]
             for (j=5;j<=7;j++) {gsub(/>.*</,">"$(j)"<",a[j+2]); print a[j+2]}
             print a[10]
             print a[11]}' template input

 

7 More Discussions You Might Find Interesting

1. Red Hat

Installing the correct version of RHEL 5 Advanced Platform.

Dear Linux Gurus and RedHat Experts, I am about to install RHEL 5 Advanced Platform x86-64 on a high end machine with 4 sockets of CPU. However, I only have the subscription number from RedHat and can log on into rhn.redhat.com. However there are only one version ISO image per CPU... (0 Replies)
Discussion started by: Zepiroth
0 Replies

2. Shell Programming and Scripting

Ask for Version of Script on Server w/o download

Hello! I'm sorry if my question is kind of a noob question, but I'm searching for a way to "ask" a Server for the Version of a File. The problem is I have several clients asking every hour or so for the newest version of the file, so if I'm just downloading a md5sum or so I'm getting a lot of... (10 Replies)
Discussion started by: al0x
10 Replies

3. UNIX for Advanced & Expert Users

Advanced Search * View * Edit JAVA version to WORK in GLASSFISH Forum topic JAVA version

Would like to confirm the ff. I got confused actually with the version I needed to download that will work on glassfish 3.0.1 a. Debian Squeeze (HP DL360). Need to use java version6 On Debian, I did apt-get install sun-java6-jdk. So when I check it's java version "1.6.0_22" Java(TM) SE... (1 Reply)
Discussion started by: lhareigh890
1 Replies

4. Shell Programming and Scripting

Script to look for new version of software

Bit of a long shot but is there a way i can have a script check a website for new version of software and dwnload it . and maybe email me when it downlaods not sure if that is even possible, to make it even worse i have to give a username and password to be able to download it thanks ... (5 Replies)
Discussion started by: ab52
5 Replies

5. Shell Programming and Scripting

Script for download file with version

Hi, Need Shell script to download the file with version or date from internet Filename will be as Eg:File-2.3.1.zip Filename will keep on changing for every 4months as File-2.3.2 or File 2.4 Thanks, Anil (4 Replies)
Discussion started by: Anil2312
4 Replies

6. UNIX for Dummies Questions & Answers

Advanced Symlink Creation script

Hello. I am working on creating a script to recursively run on my media collection. The goal is to recreate the folder structure, but with slight changes in the folder names based on my rules. The folders will also include the .jpg & .mkv files, renamed according to a similar set of rules. ... (4 Replies)
Discussion started by: Davinator
4 Replies

7. Shell Programming and Scripting

Copy a file from directroy/ prior version to the directory/ new version

How to copy a file from directroy/ prior version to the directory/ new version automatically. (4 Replies)
Discussion started by: roy1912
4 Replies
ptsematest(8)															     ptsematest(8)

NAME
ptsematest - Start two threads and measure the latency of interprocess communication with POSIX mutex. SYNTAX
ptsematest [-a|-a PROC] [-b USEC] [-d DIST] [-i INTV] [-l loops] [-p PRIO] [-t|-t NUM] DESCRIPTION
The program ptsematest starts two threads that are synchronized via pthread_mutex_unlock()/pthread_mutex_lock() and measures the latency between releasing and getting the lock. OPTIONS
-a, --affinity[=PROC] Run on procesor number PROC. If PROC is not specified, run on current processor. -b, --breaktrace=USEC Send break trace command when latency > USEC. This is a debugging option to control the latency tracer in the realtime preemption patch. It is useful to track down unexpected large latencies of a system. -d, --distance=DIST Set the distance of thread intervals in microseconds (default is 500 us). When cylictest is called with the -t option and more than one thread is created, then this distance value is added to the interval of the threads: Interval(thread N) = Interval(thread N-1) + DIST -i, --interval=INTV Set the base interval of the thread(s) in microseconds (default is 1000 us). This sets the interval of the first thread. See also -d. -l, --loops=LOOPS Set the number of loops. The default is 0 (endless). This option is useful for automated tests with a given number of test cycles. ptsematest is stopped once the number of timer intervals has been reached. -p, --prio=PRIO Set the priority of the process. -t, --threads[=NUM] Set the number of test threads (default is 1, if this option is not given). If NUM is specified, create NUM test threads. If NUM is not specifed, NUM is set to the number of available CPUs. EXAMPLES
The following example was running on a 4-way processor: # ptsematest -a -t -p99 -i100 -d25 -l1000000 #0: ID8672, P99, CPU0, I100; #1: ID8673, P99, CPU0, Cycles 1000000 #2: ID8674, P98, CPU1, I125; #3: ID8675, P98, CPU1, Cycles 811035 #4: ID8676, P97, CPU2, I150; #5: ID8677, P97, CPU2, Cycles 668130 #6: ID8678, P96, CPU3, I175; #7: ID8679, P96, CPU3, Cycles 589423 #1 -> #0, Min 1, Cur 1, Avg 2, Max 11 #3 -> #2, Min 1, Cur 2, Avg 2, Max 13 #5 -> #4, Min 1, Cur 4, Avg 3, Max 12 #7 -> #6, Min 1, Cur 4, Avg 2, Max 12 AUTHORS
Carsten Emde <C.Emde@osadl.org> SEE ALSO
pthread_mutex_lock(3p), pthread_mutex_unlock(3p) 0.1 ptsematest(8)
All times are GMT -4. The time now is 03:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy