Sponsored Content
Top Forums Shell Programming and Scripting Output format - comparison with I/p file Post 302181500 by helper on Thursday 3rd of April 2008 06:31:24 AM
Old 04-03-2008
Use SED for doing it

Case 1 : For removing multiple comma's which are together.

sed '1,$s/,,/,/' sourcefile >> targetfile


Case 2 : I understand like this.
If the id is starting with '0' then eliminate it
If its not starting with '0' then add it.

The scenario is pretty tricky...
Lets say we have a file like this
cat test
1001,aa,bb,cc,dd
1001,aa,bb,cc,dd
1001,aa,bb,cc,dd
1001,aa,bb,cc,dd
011,aa,bb,cc,dd
011,aa,bb,cc,dd
011,aa,bb,cc,dd
011,aa,bb,cc,dd
aa,bb,cc,dd
aa,bb,cc,dd
aa,bb,cc,dd
aa,bb,cc,dd
aa,bb,c,d

and if i run like this
sed '1,$s/^[1-9]/0/;1,$s/^0//' test

Check the output..

001,aa,bb,cc,dd
001,aa,bb,cc,dd
001,aa,bb,cc,dd
001,aa,bb,cc,dd
11,aa,bb,cc,dd
11,aa,bb,cc,dd
11,aa,bb,cc,dd
11,aa,bb,cc,dd
aa,bb,cc,dd
aa,bb,cc,dd
aa,bb,cc,dd
aa,bb,cc,dd
aa,bb,c,d

but we didnt need this..
We will have to distinguish between them..
so use this command.
sed '1,$s/^[1-9]/-0&/;1,$s/^0//' test >> test1
cat test1
output
======
-01001,aa,bb,cc,dd
-01001,aa,bb,cc,dd
-01001,aa,bb,cc,dd
-01001,aa,bb,cc,dd
11,aa,bb,cc,dd
11,aa,bb,cc,dd
11,aa,bb,cc,dd
11,aa,bb,cc,dd
aa,bb,cc,,dd
aa,bb,cc,,dd
aa,bb,cc,,dd
aa,bb,cc,,dd
aa,bb,c,d

Now u just have to eliminate the "-"
sed 's/^-//g' test1 >> test2
cat test2
output
=====
01001,aa,bb,cc,dd
01001,aa,bb,cc,dd
01001,aa,bb,cc,dd
01001,aa,bb,cc,dd
11,aa,bb,cc,dd
11,aa,bb,cc,dd
11,aa,bb,cc,dd
11,aa,bb,cc,dd
aa,bb,cc,dd
aa,bb,cc,dd
aa,bb,cc,dd
aa,bb,cc,dd
aa,bb,c,d

Hope i have made this clear.
Let me know if any.....
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Format the output of file

hello all Script and example of file #!/bin/sh #sh gdata.sh /users/testsuite/db/appl/ DATE=`date '+20%y-%m-%d'` echo $DATE for i in ${1}/$DATE/* ; do find $i -name daily -prune -o -name run.log -print -exec grep -c ! {} \; done > test.log. The test.log contains output like this ... (9 Replies)
Discussion started by: getdpg
9 Replies

2. Shell Programming and Scripting

format the output from a file

hi , i need to format the output which is availble in a file file output is Following are the Process_Scheduler Domains running in the server Ram-pc VPORCL Following are the Application Server domains running in the server Ram-pc VPORCL01 VPORCL02 these value VPORCL,VPORCL01...... (5 Replies)
Discussion started by: becksram123
5 Replies

3. Shell Programming and Scripting

format file output

Hi, I am trying to put a script together that allows for a command to be executed and then the output goes to a .html file. I am running the script on HPUX. I run: /var/fl/user/lmutil lmstat -a -c license_lic.dat > /web/results.html This saves the command to a .html file but the text is... (1 Reply)
Discussion started by: zerbitated
1 Replies

4. Shell Programming and Scripting

Change file output format

I have a file which has following contents usmtnz-dinfsi19 62 61 18400 18800 99.7 usmtnz-dinfsi19 62 61 18400 18800 99.7 i want the o/p to be like date (7 Replies)
Discussion started by: fugitive
7 Replies

5. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

6. Shell Programming and Scripting

format a file to this output

hi i need some help over here.. please help i have a log file as per below --------------------------------------------------------------------------------------------------------- JOB START DATE : 20110510204513 JOB ID : us2cap3ds9... (6 Replies)
Discussion started by: sitaldip
6 Replies

7. Shell Programming and Scripting

awk file comparison, x lines after matching as output

Hello, I couldn't find anything on the Forum that would help me to solve this problem. Could any body help me process below data using awk? I have got two files: file1: Worker1: Thomas Position: Manager Department: Sales Salary: $5,000 Worker2: Jason Position: ... (5 Replies)
Discussion started by: killerbee
5 Replies

8. Shell Programming and Scripting

File comparison of different format

i have file as FileD funny mou1 funny mou2 raspe mou4 damn mou1 this file is a csv with /t. i want to find all values with the first column of this file in fileB and then check for in that line if the second column vvalues are present or not . for eg... (4 Replies)
Discussion started by: rajniman
4 Replies

9. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

10. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies
CGEXEC(1)							 libcgroup Manual							 CGEXEC(1)

NAME
cgexec - run the task in given control groups SYNOPSIS
cgexec [-h] [-g <controllers>:<path>] [--sticky] command [arguments] DESCRIPTION
The cgexec program executes the task command with arguments arguments in the given control groups. -g <controllers>:<path> defines the control groups in which the task will be run. controllers is a list of controllers and path is the relative path to control groups in the given controllers list. This flag can be used multiple times to define multiple pairs of lists of controllers and relative paths. Instead of the list of all mounted controllers, the wildcard b"*b" can be used. If this option is not used, cgexec will automatically place the task in the right cgroup based on /etc/cgrules.conf. If /etc/cgrules.conf configuration file is used, there can be used template names. Then the control group name contains a template in destination tag (see cgrules.conf (5)) and if the cgroup does not exist in execution time, it is created, based on /etc/cgcon- fig.conf specification. If the specifications are not present the group is created with the default kernel values. -h, --help Display this help and exit. --sticky If running the task command with this option, the daemon of service cgred (cgrulesengd process) does not change both the task of the command and the child tasks. Without this option, the daemon does not change the task of the command but it changes the child tasks to the right cgroup based on /etc/cgrules.conf automatically. EXAMPLES
cgexec -g *:test1 ls runs command ls in control group test1 in all mounted controllers. cgexec -g cpu,memory:test1 ls -l runs command ls -l in control group test1 in controllers cpu and memory. cgexec -g cpu,memory:test1 -g swap:test2 ls -l runs command ls -l in control group test1 in controllers cpu and memory and control group test2 in controller swap. ENVIRONMENT VARIABLES
CGROUP_LOGLEVEL controls verbosity of the tool. Allowed values are DEBUG, INFO, WARNING or ERROR. FILES
/etc/cgrules.conf default libcgroup configuration file SEE ALSO
cgrules.conf (5) Linux 2009-03-15 CGEXEC(1)
All times are GMT -4. The time now is 07:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy