Sponsored Content
Top Forums Shell Programming and Scripting Need script for making files based on some conditions. Post 302944366 by ROCK_PLSQL on Tuesday 19th of May 2015 03:12:32 AM
Old 05-19-2015
Hi,

I am extremely sorry ,
Earlier I haven't formated my code_data.csv file.
Please find the data in the code_data.csv file as below.
code_data.csv

Code:
SDDCCR;  SOM   ; MD6546474777   ;
ABC   ;  KIRAN ; CB789          ;
ABC   ;  RAMANA; KS566767477747 ;
ABC   ;  KAMESH; A33535335      ;
SDDCCR;  DINESH; GD6674474747   ;
SDDCCR;  SUJAN ; SA6666464664646;
XYZ  ;   AMAR  ; AB123456       ;
XYZ  ;   RAJ   ; CS78890        ;
XYZ  ;   GANE  ; MD6546474777   ;
XXX  ;   MANO  ; MD6546474777   ;


Please find the output.

Code:
> od -ctx1 code_data.csv
0000000   S   D   D   C   C   R   ;           S   O   M               ;
          53  44  44  43  43  52  3b  20  20  53  4f  4d  20  20  20  3b
0000020       M   D   6   5   4   6   4   7   4   7   7   7
          20  4d  44  36  35  34  36  34  37  34  37  37  37  20  20  20
0000040   ;  \n   A   B   C               ;           K   I   R   A   N
          3b  0a  41  42  43  20  20  20  3b  20  20  4b  49  52  41  4e
0000060       ;       C   B   7   8   9
          20  3b  20  43  42  37  38  39  20  20  20  20  20  20  20  20
0000100           ;  \n   A   B   C               ;           R   A   M
          20  20  3b  0a  41  42  43  20  20  20  3b  20  20  52  41  4d
0000120   A   N   A   ;       K   S   5   6   6   7   6   7   4   7   7
          41  4e  41  3b  20  4b  53  35  36  36  37  36  37  34  37  37
0000140   7   4   7       ;  \n   A   B   C               ;           K
          37  34  37  20  3b  0a  41  42  43  20  20  20  3b  20  20  4b
0000160   A   M   E   S   H   ;       A   3   3   5   3   5   3   3   5
          41  4d  45  53  48  3b  20  41  33  33  35  33  35  33  33  35
0000200                           ;  \n   S   D   D   C   C   R   ;
          20  20  20  20  20  20  3b  0a  53  44  44  43  43  52  3b  20
0000220       D   I   N   E   S   H   ;       G   D   6   6   7   4   4
          20  44  49  4e  45  53  48  3b  20  47  44  36  36  37  34  34
0000240   7   4   7   4   7               ;  \n   S   D   D   C   C   R
          37  34  37  34  37  20  20  20  3b  0a  53  44  44  43  43  52
0000260   ;           S   U   J   A   N       ;       S   A   6   6   6
          3b  20  20  53  55  4a  41  4e  20  3b  20  53  41  36  36  36
0000300   6   4   6   4   6   6   4   6   4   6   ;  \n   X   Y   Z
          36  34  36  34  36  36  34  36  34  36  3b  0a  58  59  5a  20
0000320       ;               A   M   A   R           ;       A   B   1
          20  3b  20  20  20  41  4d  41  52  20  20  3b  20  41  42  31
0000340   2   3   4   5   6                               ;  \n   X   Y
          32  33  34  35  36  20  20  20  20  20  20  20  3b  0a  58  59
0000360   Z           ;               R   A   J               ;       C
          5a  20  20  3b  20  20  20  52  41  4a  20  20  20  3b  20  43
0000400   S   7   8   8   9   0                                   ;  \n
          53  37  38  38  39  30  20  20  20  20  20  20  20  20  3b  0a
0000420   X   Y   Z           ;               G   A   N   E           ;
          58  59  5a  20  20  3b  20  20  20  47  41  4e  45  20  20  3b
0000440       M   D   6   5   4   6   4   7   4   7   7   7
          20  4d  44  36  35  34  36  34  37  34  37  37  37  20  20  20
0000460   ;  \n   X   X   X           ;               M   A   N   O
          3b  0a  58  58  58  20  20  3b  20  20  20  4d  41  4e  4f  20
0000500       ;       M   D   6   5   4   6   4   7   4   7   7   7
          20  3b  20  4d  44  36  35  34  36  34  37  34  37  37  37  20
0000520           ;  \n
          20  20  3b  0a
0000524

Please help me.

Thanks,
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

creating conditions for making a new line?

Basically I want to change this: a:b c:d:e f:g h:i:j k:l into a:b c d:e f:g h i:j k:l so like if there is two :'s in one line making the first into a new line. If anyone knows how to do this I would be very appreciative! (9 Replies)
Discussion started by: Audra
9 Replies

2. Shell Programming and Scripting

validating a file based on conditions

i have a file in unix in which the records are like this aaa 123 233 aaa 234 222 aaa 242 222 bbb 122 111 bbb 122 123 ccc 124 222 In the output i want only the below records aaa ccc The validation logic is 1st column and 2nd column need to be considered if both columns values are... (8 Replies)
Discussion started by: trichyselva
8 Replies

3. UNIX for Dummies Questions & Answers

any script for joining files based on simple conditions

Condition1; If NPID and IndID of both input1 and input2 are same take all the vaues relevant to them and print together as output Condition2; IDNo in output: Take the highly repeated same letter of similar NPID-IndID as *1* Second highly repeated same letter... (0 Replies)
Discussion started by: stateperl
0 Replies

4. Shell Programming and Scripting

awk merging files based on 2 complex conditions

1. if the 1st row IDs of input1 (ID1/ID2.....) is equal to any IDNames of input2 print all relevant values together as defined in the output. 2. A bit tricky part is IDno in the output. All we need to do is numbering same kind of letters as 1 (aa of ID1) and different letters as 2 (ab... (4 Replies)
Discussion started by: ruby_sgp
4 Replies

5. Shell Programming and Scripting

PHP Script Help - Making links to files Clickable

Ok so I wrote a php script that outputs the below to users on a webpage. # Download: /home/content/d/i/v/divine1234/eBookDownloads/ScalpRemedy_jablaa12734.zip the php code that outputs the above is: echo ("<li>Download: $download_link</li>\n"); The thing is, I dont want... (1 Reply)
Discussion started by: SkySmart
1 Replies

6. Shell Programming and Scripting

Report generation based on certain conditions

Hi I recently joined a project where I have been asked to generate a report using shell script accessing UNIX box. I have no idea on how to do it as I am a beginner and learning shell scripts. Suppose I have a XML: Code: ... (3 Replies)
Discussion started by: vat1kor
3 Replies

7. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file based on certain conditions

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 5 columns having values say column 1,column 2.....column 5 as below along with their valuesm.... (1 Reply)
Discussion started by: Vivekit82
1 Replies

8. Shell Programming and Scripting

Making a script to copy files not seen before (using md5sum)

Hello, I would like to make a script that searches through a SRC folder and copies only files it's never seen before to a DEST folder. SRC = /user/.phonesync/photos-backup DST = /usr/.phonesync/photos-new So basically, I'd start with a: md5sum /user/.phonesync/photos-backup/* >... (29 Replies)
Discussion started by: nbsparks
29 Replies

9. Shell Programming and Scripting

Split File based on different conditions

I need to split the file Conditions: Ignore any record that either starts with 1 or 9 Split the file at position 404 , if position 404 is abc or def then write all the records in a file > File 1 , the remaining records should go in to a file > File 2 Further I want to split the... (7 Replies)
Discussion started by: protech
7 Replies

10. Shell Programming and Scripting

Merge input from two files into one based on conditions

Using Linux (bash), I have two files which contain information about berries. Example: file1.txt: Blueberry blue 14 Raspberry red 12 Blackberry dark 4 file2.txt Blackberry sour 4 3 Blueberry tasty 12 78 Strawberry yummy 33 88 I want to merge these two files into one. The desired... (5 Replies)
Discussion started by: Zooma
5 Replies
Linux::Distribution::Packages(3pm)			User Contributed Perl Documentation			Linux::Distribution::Packages(3pm)

NAME
Linux::Distribution::Packages - list all packages on various Linux distributions SYNOPSIS
use Linux::Distribution::Packages qw(distribution_packages distribution_write); $linux = new Linux::Distribution::Packages({'format' => 'csv', 'output_file' => 'packages.csv'}); $linux->distribution_write(); # Or you can (re)set the options when you write. $linux->distribution_write({'format' => 'xml', 'output_file' => 'packages.xml'}); # If you want to reload the package data $linux->distribution_packages(); DESCRIPTION
This is a simple module that uses Linux::Distribution to guess the linux distribution and then uses the correct commands to list all the packages on the system and then output them in one of three formats: native, csv, and xml. Distributions currently working: debian, ubuntu, fedora, redhat, suse, gentoo, slackware, redflag. The module inherits from Linux::Distribution, so can also use its calls. EXPORT None by default. TODO
* Add the capability to correctly get packages for all recognized distributions. * Seperate out parsing from writing. Parse data to hash and give access to hash. Then write the formatted data from the hash. AUTHORS
Judith Lebzelter, <judith@osdl.org> Alberto Re, <alberto@accidia.net> COPYRIGHT AND LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available. perl v5.10.1 2006-04-19 Linux::Distribution::Packages(3pm)
All times are GMT -4. The time now is 08:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy