help with generate a new text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with generate a new text
# 1  
Old 09-20-2012
help with generate a new text

textfile 1
Code:
BRM501,LOGON,BX12_28,2012 SEP 20 15:01:58
BRM502,LOGOFF,BX12_34,2012 SEP 20 14:56:06
BTT396,LOGON,BT03_8,2012 SEP 20 15:03:08

textfile 2
Code:
BRM501,DEPLOYED
BRM502,DEPLOYED

to combine 2 textfile result together and create new file
result
Code:
BRM501,LOGON,BX12_28,2012 SEP 20 15:01:58,DEPLOYED
BRM502,LOGOFF,BX12_34,2012 SEP 20 14:56:06,DEPLOYED
BTT396,LOGON,BT03_8,2012 SEP 20 15:03:08, UNDEPLOYED

KShell
Hi guys I need a format or an approach to this problem i am facing to combine 2 log and generate a new result.. help is very much appreciated..
i have 100 of records in textfile 1 and 77 records in textfile 2. So I pretty much need to start with loops =(

Last edited by Franklin52; 09-20-2012 at 09:29 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 09-20-2012
Code:
awk -F, 'FNR==NR{a[$1]=$2;next}{$(NF+1)=($1 in a)?a[$1]:"UNDEPLOYED"}1' OFS=, file2 file1

Is this what you what?
This User Gave Thanks to elixir_sinari For This Post:
# 3  
Old 09-20-2012
Quote:
Originally Posted by elixir_sinari
Code:
awk -F, 'FNR==NR{a[$1]=$2;next}{$(NF+1)=($1 in a)?a[$1]:"UNDEPLOYED"}1' OFS=, file2 file1

Is this what you what?
Code:
#remove header and footer
sed '1,16 d' </tmp/$resultEqpt_dir >/tmp/$resultEqpt_dir.out
sed '111,116 d' </tmp/$resultEqpt_dir.out >/tmp/$resultEqpt.log
#Housekeeping: Delete the result temp file
rm /tmp/$resultEqpt_dir.out
rm /tmp/$resultEqpt_dir
#Execute the second SQL query
$cur_dir/select-eqptDeployment-bt-status > /tmp/$resultEqptstatus_dir
#remove header and footer
sed '1,16 d' </tmp/$resultEqptstatus_dir >/tmp/$resultEqptstatus_dir.out
sed '88,93 d' </tmp/$resultEqptstatus_dir.out >/tmp/$resultEqptstatus.log

#Housekeeping: Delete the result temp file
rm /tmp/$resultEqptstatus_dir.out
rm /tmp/$resultEqptstatus_dir
awk -F, 'FNR==NR{a[$1]=$2;next}{$(NF+1)=($1 in a)?a[$1]:"UNDEPLOYED"}1' OFS, /tmp/$resultEqpt.log /tmp/$resultEqptstatus.log

I gt my error:
Code:
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1

is it cos i had perform sed earlier?

Last edited by Franklin52; 09-20-2012 at 09:28 AM.. Reason: Please use code tags for data and code samples
# 4  
Old 09-20-2012
Use nawk or /usr/xpg4/bin/awk instead of awk.
# 5  
Old 09-21-2012
Quote:
Originally Posted by elixir_sinari
Use nawk or /usr/xpg4/bin/awk instead of awk.
nope still cant work Smilie

---------- Post updated 09-21-12 at 10:51 AM ---------- Previous update was 09-20-12 at 06:22 PM ----------

Quote:
Originally Posted by ment0smintz
textfile 1
Code:
BRM501,LOGON,BX12_28,2012 SEP 20 15:01:58
BRM502,LOGOFF,BX12_34,2012 SEP 20 14:56:06
BTT396,LOGON,BT03_8,2012 SEP 20 15:03:08

textfile 2
Code:
BRM501,DEPLOYED
BRM502,DEPLOYED

to combine 2 textfile result together and create new file
result
Code:
BRM501,LOGON,BX12_28,2012 SEP 20 15:01:58,DEPLOYED
BRM502,LOGOFF,BX12_34,2012 SEP 20 14:56:06,DEPLOYED
BTT396,LOGON,BT03_8,2012 SEP 20 15:03:08, UNDEPLOYED

KShell
Hi guys I need a format or an approach to this problem i am facing to combine 2 log and generate a new result.. help is very much appreciated..
i have 100 of records in textfile 1 and 77 records in textfile 2. So I pretty much need to start with loops =(
i m looking for the solution that is if txtfile 1 have the record file found in txtfile 2.
new > result file will have txtfile1 with line + 'DEPLOYED'
else if record file is not found in txtfile 2 +'UNDEPLOYED'

---------- Post updated at 11:32 AM ---------- Previous update was at 10:51 AM ----------

solution found... thanks elixir_sinari
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generate hexadecimal

Hello I'm working on a script to list all ipv6 from given address so I've run this script which create hex part of ipv6 STR2=159 END2=200 SUM2=`expr $END2 - $STR2` for ((i=STR2;i<=END2;++i)); do x=$( printf "%x" $i ) ; echo $x echo -e "::"$x >> netpart.txt done output is : ::9f... (2 Replies)
Discussion started by: nimafire
2 Replies

2. Shell Programming and Scripting

Generate .csv file a text file

Hi guys, I have a text file that states: cat prod.hosts 11.29.130.14 host1 host1.test.com web17 11.29.130.15 host2 host2.test.com web18 11.29.130.16 host3 host3.test.com web19 I want a .csv file that states: ... (2 Replies)
Discussion started by: Junaid Subhani
2 Replies

3. Shell Programming and Scripting

a shell script to generate an excel sheet from a text file..

hi, i have a text file that looks like this! i want to generate an excel sheet out of it, removing all the junk data except the addresses that look like . Arrow Electrical Services Rotating Machinery, Electrical Contracting & Mining Specialists Onsite maintenance, breakdown... (8 Replies)
Discussion started by: vemkiran
8 Replies

4. Shell Programming and Scripting

KSH - help needed for creating a script to generate xml file from text file

Dear Members, I have a table in Oracle DB and one of its column name is INFO which has data in text format which we need to fetch in a script and create an xml file of a new table from the input. The contents of a single cell of INFO column is like: Area:app - aam Clean Up Criteria:... (0 Replies)
Discussion started by: Yoodit
0 Replies

5. Shell Programming and Scripting

generate tabular output from an input text file in unix shell scripting

Hi, I have the output (as below) which i want it to be in a table. For e.g. space utilization in PSE on path /logs is 0% space utilization in PSE on path /logs/tuxedo/tuxlsp is 16% space utilization in PSE on path /ldvarlsp/lsp/log is 37% space utilization in PSE on path /home is 6%... (7 Replies)
Discussion started by: pkbond
7 Replies

6. UNIX for Dummies Questions & Answers

How to generate multiple lines in a text file?

Hello, I want to create a file whose content is multiple lines of strings. The string has the following pattern: aaaa/bbbb/A-B.txt A is a variable ranges from A1 to A2 B is a variable ranges from B1 to B2 Any ideas? Thanks. (17 Replies)
Discussion started by: vic005
17 Replies

7. Shell Programming and Scripting

generate a report

I am trying to generate a report for a file called phone_book awk -f {phone_book} why does this not work? Nothing happens at all. (2 Replies)
Discussion started by: gustave
2 Replies

8. Shell Programming and Scripting

Generate a XML file from a text file

FILE-1 USER username@foo.com TOOLIN tool-a TOOL2 tool-b TOOL3 tool-c TOOL4 tool-d TOOL5 tool-e USER username_2@foo.com TOOLIN tool-e TOOL2 tool-f TOOL3 tool-c TOOL4 tool-d .... I need to take this file and generate a target XML file - <access> <managed> ... (3 Replies)
Discussion started by: jacki
3 Replies

9. UNIX for Dummies Questions & Answers

Script to generate text file from excel file

Hello, I have a excel file which has almost ten columns on the shared drive. I have to write a shell script to ftp that daily to unix server and then extract some columns from there and generate oracle standard text file. The columns should be in proper order and aligned properly, otherwise... (1 Reply)
Discussion started by: isingh786
1 Replies

10. Shell Programming and Scripting

generate new string from a text file

Hi, I have a file and the content looks like this: line1 line2 File #5 : found '/u01/testing.txt' line5 line6 line7 File #12 : found '/u01/testabc.txt' line10 line11 I want to write a bash script to give me the output: The file 5 is '/u01/testing.txt' The file 12 is... (6 Replies)
Discussion started by: walterwaston
6 Replies
Login or Register to Ask a Question