Sponsored Content
Top Forums Shell Programming and Scripting Need an advanced version of this script Post 302439232 by shasha7 on Thursday 22nd of July 2010 05:59:55 AM
Old 07-22-2010
Thanks Scrutinizer. Both versions of the script work like magic. The expect uotput format is this:

Code:
<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>
</label>
<label>
  <Spalte_1>Datensatz 2 Spalte 1</Spalte_1>
  <Spalte_2>Datensatz 2 Spalte 2</Spalte_2>
  <Spalte_3>Datensatz 2 Spalte 3</Spalte_3>
  <Spalte_4>Datensatz 2 Spalte 4</Spalte_4>
</label>
<label>
  <Spalte_1>Datensatz 3 Spalte 1</Spalte_1>
  <Spalte_2>Datensatz 3 Spalte 2</Spalte_2>
  <Spalte_3>Datensatz 3 Spalte 3</Spalte_3>
  <Spalte_4>Datensatz 3 Spalte 4</Spalte_4>
</label>
<label>
  <Spalte_1>Datensatz 4 Spalte 1</Spalte_1>
  <Spalte_2>Datensatz 4 Spalte 2</Spalte_2>
  <Spalte_3>Datensatz 4 Spalte 3</Spalte_3>
  <Spalte_4>Datensatz 4 Spalte 4</Spalte_4>
</label>
<label>
  <Spalte_1>Datensatz 5 Spalte 1</Spalte_1>
  <Spalte_2>Datensatz 5 Spalte 2</Spalte_2>
  <Spalte_3>Datensatz 5 Spalte 3</Spalte_3>
  <Spalte_4>Datensatz 5 Spalte 4</Spalte_4>
</label>

There are only 2 things to do for me reight now. To implement one sublabel, as my real data set looks like that:

Code:
'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

Expected output would be like that:
Code:
<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>

I think i have an idea to do that. I'll run the script 2 times and merge the 2 different output files later (one containing the label, the other one the sublabel).

The other plan is to buy some books on shell scripting Smilie

You helped me a lot already, thanks for that.

@rdcwayx: awk seem to be a very mighty tool, i have to learn a lot.
 

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
SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-a] [-c COMMAND] [-e] [-f] [-q] [-t] [file] DESCRIPTION
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. Options: -a Append the output to file or typescript, retaining the prior contents. -c COMMAND Run the COMMAND rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty. -e Return the exit code of the child process. Uses the same format as bash termination on signal termination exit code is 128+n. -f Flush output after each write. This is nice for telecooperation: One person does `mkfifo foo; script -f foo' and another can super- vise real-time what is being done using `cat foo'. -q Be quiet. -t Output timing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time. This information can be used to replay typescripts with realistic typing and output delays. The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism), scriptreplay(1). HISTORY
The script command appeared in 3.0BSD. BUGS
Script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. AVAILABILITY
The script command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/. Linux July 30, 2000 Linux
All times are GMT -4. The time now is 10:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy