generate a file from existing file based on some rule


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting generate a file from existing file based on some rule
# 1  
Old 06-16-2011
generate a file from existing file based on some rule

Hi guys,
i have a file in below format.let me explain first what i am trying to do .
i am making a file from this file , will rearrange these columns, then i will run several command(start/stop mentioned in this file) on unix environment. my requirements :
1. i have 27 servers , on each server 34 processes are running so 34*27 rows are present in this file . each line is having start command- 3rd column, stop command - 5th column . so now , i want for each server , merge these 27 rows in 1 row ; but i want all 27rows start/stop command in that single row , so that if a program reads this file for command , it gets all commands and fire it on server. i tried to put commands in single line seperated by semicolon ;, but then vi editor gave me error, that not more than 200 charaters can put in a single line .
can someone sugest how to do that ? also ,logic to combine these 27 rows in 1 row, having all 3rd and 5th column in that row's 3rd and 5th column ?
hope it's clear , otherwise pls reply back
#COMMON_NAME # LOGICAL_NAME # ACTUAL_DAEMON_NAME # START_COMMAND # PARAMETERS # STOP_COMMAND # CPU # USER # IS_AUTO_LOAD_FLAG # MAX_LIMIT # FROM_TIME # UNTIL_TIME # CHECK_FOR_NEW # GROUP # RESTART_FLAG
# 2  
Old 06-16-2011
I read your requirements three times and I am still confused.

Could you please display a sample of the input and based on this input, the desired output?

Thank you.
# 3  
Old 06-16-2011
Smilie sorry.
input file :-
Code:
# aaa # aaa # abab # mkdir # -p # exit # CPU # USER # FLAG # LIMIT # FROM # UNTIL # ll -lart # G1 # RESTART_FLAG 
# bbb # bbb # baba # cd # . # ll # CPU # USER # FLAG # LIMIT # FROM # UNTIL # cd # G2 # RESTART_FLAG

so on lots of line (27*34) - 27 server , for each server 34 rows

output :- i am concerned on 3rd and 5th columns values
Code:
# G # G # anything # mkdir;cd;3rd row cmd;34th row cmd # . # exit;ll;3rd row cmd...34th row cmd # CPU # USER # FLAG # LIMIT # FROM # UNTIL # cd # G2 # RESTART_FLAG

ultimately i want , if some programs read first line for 1st server - it must take data from 3rd column (it wil take as per it's logic, dont worry abt that) and fire on unix account. but again , i can't combine 34 rows start/stop command in 1 line , and it should work on unix env. but Vi is not accepting so many characters in one line.
i want to fire all 34 commands on unix env in one shot .i can run those commands parellely as well, but in that case , unix account cannot bear 34 commands on one server and so it doesn't work, it's accepting 10-11 commands only in parellel.

Last edited by Yogesh Sawant; 06-16-2011 at 05:54 PM.. Reason: added code tags
# 4  
Old 06-16-2011
Now I am more confused and even have more questions.

Let's try the following:

Display a sample REAL input.

Display the equivalent desired output based on the REAL input.

No words this time.
# 5  
Old 06-17-2011
INPUT file:
Code:
RB0112 # RB0112 # grep cmd1  # start1 #  # stop1 # xxx #  yyy # 0 # 1 # # # # RBP2 # no
XLAOLC2542 # XLAOLC2542 # grep cmd2 # start2 # # stop  # xxx # yyy # 0 # 1 # # # # XLA # yes
SED011 # SED011 # grep cmd3 # start3 # # stop3 # xxx # yyy # 0 # 1 # # # # SED # yes
RBF042 # RBF042 # grep cmd4 # start4 # # stop4 # xxx # yyy # 0 # 1 # # # # RBFOFFS # no

OUTPUT File:
i want to merge 4 and 6 columns respectively
(note in input file , columns , xxx and yyy are same)
Code:
RB # RB # Common_Name  # start1;start2;start3;start #  # stop1;stop2;stop3;stop4 # xxx #  yyy # 0 # 1 # # # # RBP1 # no

u can ignore rest of the columns, just merge columns 4 and 6 of some set of rows based on similar xxx and yyy columns .
here limitation is - start1,start2..... and stop1 , stop2.... have lots of characters and so if we combile all of them in a single line , VI doesn't allow .
unix env limitation , i already explained. i want all those (34 commands) fire on unix env in one shot. if i fire in parellel , one line each from input file, they r not working .if i seperate commands by semicolon ;i can fire all 34 commands in one shot , and they will execute

---------- Post updated at 03:49 PM ---------- Previous update was at 04:02 AM ----------

anyone ?

Last edited by Scott; 06-16-2011 at 06:05 PM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

In PErl script: need to read the data one file and generate multiple files based on the data

We have the data looks like below in a log file. I want to generat files based on the string between two hash(#) symbol like below Source: #ext1#test1.tale2 drop #ext1#test11.tale21 drop #ext1#test123.tale21 drop #ext2#test1.tale21 drop #ext2#test12.tale21 drop #ext3#test11.tale21 drop... (5 Replies)
Discussion started by: Sanjeev G
5 Replies

2. Shell Programming and Scripting

How to create file and file content based existing information?

Hi Gurus, I am SQL developer and new unix user. I need to create some file and file content based on information in two files. I have one file contains basic information below file1 and another exception file file2. the rule is if "zone' and "cd" in file1 exists in file2, then file name is... (13 Replies)
Discussion started by: Torhong
13 Replies

3. Shell Programming and Scripting

Generate tabular data based on a column value from an existing data file

Hi, I have a data file with : 01/28/2012,1,1,98995 01/28/2012,1,2,7195 01/29/2012,1,1,98995 01/29/2012,1,2,7195 01/30/2012,1,1,98896 01/30/2012,1,2,7083 01/31/2012,1,1,98896 01/31/2012,1,2,7083 02/01/2012,1,1,98896 02/01/2012,1,2,7083 02/02/2012,1,1,98899 02/02/2012,1,2,7083 I... (1 Reply)
Discussion started by: himanish
1 Replies

4. Shell Programming and Scripting

Generate files from one file based on lines

Hi Friends, I have a file1 file1.txt 1ABC 13478 aqjerh 473 343 2hej 478 5775 24578 23892 3fhd fg 847 brjkb f99345 487 4eh ehjk 84 47589 8947 234 5784 487 738 52895 8975 6 57489 eghe9 4575 859479 7fnbd 4y5 4iuy 458 h irh 8fjdg 74 7845 8475 5789 94yr 48yr 4hr erhj reh... (3 Replies)
Discussion started by: i150371485
3 Replies

5. Shell Programming and Scripting

How to generate a csv files by separating the values from the input file based on position?

Hi All, I need help for doing the following. I have a input file like: aaaaaaaaaabbbbbbbbbbbbbbbbbbbb cccbbbbbaaaaaadddddaaaabbbbbbb now I am trying to generate a output csv file where i will have for e.g. 0-3 chars of each line as the first column in the csv, 4-10 chars of the line as... (3 Replies)
Discussion started by: babom
3 Replies

6. Shell Programming and Scripting

Creating a new file based on existing file

Hello Guys , I need an another help regarding the below problem. I want to create a new file based on the existing file ,where two columns will be changed according to user input .(say column 4 and column 5) Please let me know how to proceed with Thanks (3 Replies)
Discussion started by: Pratik4891
3 Replies

7. Shell Programming and Scripting

folder existing and file existing

I want to look into a folder to see if there are any folders within it. If there are, I need to check inside each folder to see if it contains a .pdf file So If /myserver/myfolder/ contains a folder AND that folder conatins a .pdf file do X Else do Z I may have multiple folders and... (4 Replies)
Discussion started by: crowman
4 Replies

8. Shell Programming and Scripting

Creating a csv file based on Existing file

Hi I am Newbie to Unix.Appreciate Help from forum user would loada b.Csv File(Below example) in /data/m/ directory.Program need to read the b.csc to extract certain column and create a new file /data/d/ directory as csv file with new name. User File Format 1232,samshouston,12345... (3 Replies)
Discussion started by: skywayterrace
3 Replies

9. Shell Programming and Scripting

search file, change existing value based on input (awk help)

I have a file (status.file) of the form: valueA 3450 valueB -20 valueC -340 valueD 48 I am tailing a data.file, and need to search and modify a value in status.file...the tail is: tail -f data.file | awk '{ print $3, ($NF - $(NF-1)) }' which will produce lines that look like this: ... (3 Replies)
Discussion started by: nortonloaf
3 Replies

10. Shell Programming and Scripting

i want to delete a file based on existing file in a directory

hi i am having four files in a directory.like 1)sampleRej 2)exampleRej 3)samplemain 4)examplemain my requirement is i have to search for the rejected files (sampleRej,exampleRej) in a directory.if these files in that directory then i have to delete the main files... (3 Replies)
Discussion started by: srivsn
3 Replies
Login or Register to Ask a Question