Sponsored Content
Full Discussion: Write result to output file
Top Forums Shell Programming and Scripting Write result to output file Post 302628727 by bluejean1976 on Tuesday 24th of April 2012 01:32:45 AM
Old 04-24-2012
Write result to output file

Good morning everybody,

Beeing an absolute newbie in shell scripting I would like to look for some help here.

I would like to read an external text file and format the data and write it to an output file.

What I was trying to do was to display the result (this worked).

But now I would like to write this result to a external file.

I would appreciate that some of you guys could help me out with this.

Here is what I did.

Code:
#!/usr/bin/perl
$data_file="theoriginalfile";
 
open(DAT, $data_file) || die("Could not open file!");
@raw_data=<DAT>;
close(DAT);
## Start input to the output file
print "\$H:CREATE";
print "\n";
print "\$H:hardcodeevalue,hardcodeevalue,hardcodeevalue,hardcodeevalue";
print "\n";
foreach $lineintheoriginalfile (@raw_data)
{
chomp($lineintheoriginalfile );
($val1,$val2,$val3,$val4,$val5)=split(/\;/,$simline);
print "\$R:<PARENT>hardcodeevalue,${val1},,hardcodeevalue,,hardcodeevalue='':hardcodeevalue=${val2}:hardcodeevalue=${val3}:hardcodeevalue=${val4}:Profile=hardcodeevalue:A4KI=1:Model=hardcodeevalue:ADM=AA:Manufacturer=hardcodeevalue:OTA Key=1111 <CHILD>hardcodeevalue,${val5
},,L
OAD,,,";
print "\n";
}
print "\$F:";
#end input to the output file
print "\n";

the external file is similar to this
Code:
val1;val2;val3;val4;val5
val1;val2;val3;val4;val5
val1;val2;val3;val4;val5

I hope it's clear Smilie

Thank's a lot,

Moderator's Comments:
Mod Comment Welcome to the UNIX and Linux Forums. Please use [code] tags. Video tutorial on how to use them

Last edited by Scrutinizer; 04-24-2012 at 03:08 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

any possible to run sql result and output to file

Hi, I search all post...and no soluation about..if i would like to run a sql statement and output the result to txt file. for example, i usually run "sql" to logon the database and run select statement. Then I need to copy the output into the result.txt. Can I run the script to do this... (7 Replies)
Discussion started by: happyv
7 Replies

2. Shell Programming and Scripting

Need to Output result to a non-delimitted file

Hello I need to run an sql script and then the output result to be in non-delimitted file What is the execution command to obtain this. For eg: the following outputs the result to a space delimitted file db2batch -d ${EC_DB2_DBNAME} -f ${TMP_SCRIPT_NAME} -a ${CURR_DB_ID}/${CURR_DB_PWD} -r... (1 Reply)
Discussion started by: cosec
1 Replies

3. Shell Programming and Scripting

Way to save output result of a program into another new file...

Does anybody know any alternative way to save output result of a program into another new file? I got try the command below: program_used input_file > new_output_file program_used input_file >> new_output_file Unfortunately, both the ">" and ">>" is not work at this case to save the output... (6 Replies)
Discussion started by: patrick87
6 Replies

4. UNIX for Advanced & Expert Users

Output the SQL Query result to a File

Hello Guys, This message is somewhat relates with last thread. But I need to re-write thing. I start over a little. I am stuck now and need your help. Here is my script- #! /bin/ksh export ORACLE_HOME=/opt/oracle/app/oracle/product/9.2 /opt/oracle/app/oracle/product/9.2/bin/sqlplus -s... (5 Replies)
Discussion started by: thepurple
5 Replies

5. Shell Programming and Scripting

How to output thre result to a text file?

Dear All I have a script file like the following: ..... ..... Variable_1 = 888 Variable_2 = 999 ..... MyExternalProgram Myfile ..... The line MyExternalProgram Myfile will generate some number, Say 777 Now I hope I can output the result of above codes to a text file,... (2 Replies)
Discussion started by: littlewenwen
2 Replies

6. Shell Programming and Scripting

Script to write result to a file

Hello, How can I run this script every 1 hour and save its result to result.txt ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' Regards Shaan (5 Replies)
Discussion started by: Shaan_Shaan
5 Replies

7. Shell Programming and Scripting

Compare 2 file and write result

Hi friends...I have 2 files, file1.txt and reference.txt I could able to find difference using diff and following command awk 'NR == FNR { A=1; next } !A' reference.txt file1.txt above command listing data which is not in reference.txt 12.12 87 11.95 88 11.83 89 12.55 84... (12 Replies)
Discussion started by: Akshay Hegde
12 Replies

8. Shell Programming and Scripting

Output block of lines in a file based on grep result

Hi I would appreciate your help with this. I have a output file from a command. It is broken based on initial of the users. Exmaple of iitials MN & SS. Under each section there is information pertaining to the user however each section can have different number of lines. MY challenge is to ... (5 Replies)
Discussion started by: mnassiri
5 Replies

9. Shell Programming and Scripting

Curl and write custom result to file

I have the following script, for i in $(cat MyWebApps); do curl -u manager:tH1s1s4f3k3p4ssw0Rd http://10.10.10.10:7529/manager/jmxproxy/"?get=Catalina:type=Manager,context=/$i,host=localhost&att=activeSessions"; done Which gives me an output like this OK - Attribute get... (12 Replies)
Discussion started by: charli1
12 Replies

10. Shell Programming and Scripting

Grep output to file result not as expected

Hi Gurus, I run command grep ABC file1 > file2 against below file. I got all ABC_xxx in one line in file2. I expect to get multiple lines in file2. If I print result in screen, the result is expected. thanks in advance My os is SunOS 5.10 Generic_150400-64 sun4v sparc sun4v ABC_123 XXXXX... (2 Replies)
Discussion started by: green_k
2 Replies
DWARF_ADD_FDE_INST(3)					   BSD Library Functions Manual 				     DWARF_ADD_FDE_INST(3)

NAME
dwarf_add_fde_inst -- add a call frame instruction to a DWARF frame descriptor LIBRARY
DWARF Access Library (libdwarf, -ldwarf) SYNOPSIS
#include <libdwarf.h> Dwarf_P_Fde dwarf_add_fde_inst(Dwarf_P_Fde fde, Dwarf_Small op, Dwarf_Unsigned val1, Dwarf_Unsigned val2, Dwarf_Error *err); DESCRIPTION
Function dwarf_add_fde_inst() adds a call frame instruction to the DWARF frame descriptor referenced by argument fde. Argument fde should reference a frame descriptor allocated using dwarf_new_fde(3). Argument op specifies the operator for the frame instruction. The DWARF standard defines the set of legal values for this argument. Argument val1 specifies the first operand of the frame instruction. Argument val2 specifies the second operand of the frame instruction. If argument err is not NULL, it will be used to store error information in case of an error. RETURN VALUES
On success, function dwarf_add_fde_inst() returns the frame descriptor given in argument fde. In case of an error, function dwarf_add_fde_inst() returns DW_DLV_BADADDR and sets the argument err. ERRORS
Function dwarf_add_fde_inst() can fail with: [DW_DLE_ARGUMENT] Argument fde was NULL. [DW_DLE_FRAME_INSTR_EXEC_ERROR] The frame instruction operator specified in argument op was invalid. [DW_DLE_MEMORY] An out of memory condition was encountered during the execution of the function. SEE ALSO
dwarf(3), dwarf_add_frame_fde(3), dwarf_add_frame_fde_b(3), dwarf_add_frame_cie(3), dwarf_fde_cfa_offset(3), dwarf_new_fde(3) The DWARF Debugging Information Format, Version 4, http://www.dwarfstd.org/. BSD
September 26, 2011 BSD
All times are GMT -4. The time now is 02:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy