Sponsored Content
Top Forums Shell Programming and Scripting Unfold the data from a input file and write to a file Post 302564848 by svajhala on Friday 14th of October 2011 10:08:13 PM
Old 10-14-2011
Unfold the data from a input file and write to a file

I am working on a script to unfold data for each column from a specific line of data and write output in a single line.

Input data looks like this.

HTML Code:
2011-09-26 INF UM_10 UserMana Starting synchronization for security domain
14:37:31       080   gementSe [12345].
                     rvice
I prepared the script to unfold the above data

HTML Code:
#!/usr/bin/ksh
while read mDate mRest; do
  if [[ ${#mDate} -eq 10 ]]; then
    if [[ "${mOut}" != "" ]]; then
      echo ${mOut}
    fi
    mOut=''
  fi
  mOut=${mOut}' '${mDate}' '${mRest}
done < Inp_File
if [[ "${mOut}" != "" ]]; then
  echo ${mOut}
fi

The problem with this script is it simply cuts the data from 2nd and 3rd lines and attaches to the first line.

HTML Code:
2011-09-26 INF UM_10 UserMana Starting synchronization for security domain 08:45:10 080 gementSe [12345]. rvice
But I want the data to be like this:

HTML Code:
2011-09-26 14:37:31 INF UM_10080 UserManagementService Starting synchronization for security domain [12345].
Thanks,
Bob
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need script to take input from file, match on it in file 2 and input data

All, I am trying to figure out a script to run in windows that will allow me to match on First column in file1 to 8th Column in File2 then Insert file1 column2 to file2 column4 then create a new file. File1: 12345 Sam 12346 Bob 12347 Bill File2:... (1 Reply)
Discussion started by: darkoth
1 Replies

2. Shell Programming and Scripting

get data from input file and write another file

Hi, i have doubt in read and write using bash shell script... i will give the input file path and output file path in command line ex : example.sh iputfile outpilepath Here i need to read the input data then write that data to output file.. please give some example : (6 Replies)
Discussion started by: karthinvk
6 Replies

3. Shell Programming and Scripting

Extract data from an XML file & write into a CSV file

Hi All, I am having an XML tag like: <detail sim_ser_no_1="898407109001000090" imsi_1="452070001000090"> <security>ADM1=????</security> <security>PIN1=????</security> <security>PIN2=????</security> ... (2 Replies)
Discussion started by: ss_ss
2 Replies

4. Shell Programming and Scripting

Read the apecific data from one file and write into another file

Hi, I would like to read the specific data from file and write the data in the new file. My data input is something like this.. <EXROP:R=TJ0311T; ROUTE DATA R ROUTE PARAMETERS TJ0311T DETY=UPDR TTRANS=1 FNC=3 MA=628160955000 R=TJ0311D ... (3 Replies)
Discussion started by: bha148
3 Replies

5. Shell Programming and Scripting

Help to write a script or program to automatic execute and link input file data

Output file template format <input_file_name>a</input_file_name> <total_length_size>b</total_length_size> <log_10_length_size>c</log_10_length_size> Input_file_1 (eg. sample.txt) SDFSDGDGSFGRTREREYWW Parameter: a is equal to the input file name b is equal to the total length of... (2 Replies)
Discussion started by: perl_beginner
2 Replies

6. Shell Programming and Scripting

Read user input, Encrypt the data and write to file

Hi, can some one help me how to encrypt and decrypt a file. AIM: reade user input, encrypt it and save it to file. while decryption read the encrypted file decrypt it and save the output in some variable. Example: consider we have Credentials.txt file with content username: password... (5 Replies)
Discussion started by: saichand1985
5 Replies

7. Shell Programming and Scripting

Extract data from XML file and write in CSV file

Hi friend i have input as following XML file <?xml version="1.0"?> <Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.054.001.02"> <BkToCstmrDbtCdtNtfctn> <GrpHdr><MsgId>LBP-RDJ-TE000000-130042430010001001</MsgId><CreDtTm>2013-01-04T03:21:30</CreDtTm></GrpHdr>... (3 Replies)
Discussion started by: mohan sharma
3 Replies

8. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

9. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

10. Shell Programming and Scripting

awk to reformat output if input file is empty, but not if file has data in it

The below awk improved bu @MadeInGermany, works great as long as the input file has data in it in the below format: input chrX 25031028 25031925 chrX:25031028-25031925 ARX 631 18 chrX 25031028 25031925 chrX:25031028-25031925 ARX 632 14... (3 Replies)
Discussion started by: cmccabe
3 Replies
MAPHIMBU(1)							   User Commands						       MAPHIMBU(1)

NAME
maphimbu - histogram builder for 1-d numerical and text data SYNOPSIS
maphimbu [OPTION]... [FILE] DESCRIPTION
This program produces 1-d histograms from numerical or text data input. It can be also used to estimate the probability distribution func- tion of a numerical variable - see http://en.wikipedia.org/wiki/Probability_density_function. OPTIONS
-x <int> x-data column (default is 1) -y <int> y-data column (default is 2); It is considered only when combined with '-m' or '-S' -d <float|int> delta size (dx-resolution) in case of numerical data; Keep in mind that 2 is not the same as 2.0: in the first case the numbers are treated as integers, in the latter as floats. -n normalize the result A) non-numerical data: n(x) = counts(x)/sum_of_counts B) numerical data: the normalized probability density func. is P(-INF < x <INF) = Int_[-INF:INF] P(x)*dx = 1 ; For the numerical integration an open x-data interval is assumed. -N normalize data against the total sum of counts (same as option '-n' with case A forced) -U normalize the result with x-range mapped to unit; The x-values are mapped to the interval [0:1], respectively Int_[0:1] P(x)*dx = 1; This option is mutually exclusive with '-n'. -S compute sums and normalized sums of y-values; The total sum of all y-values is used for the normalization. -m compute the arithmetic mean of y-values in the respective x-bar -s <int> sort output using the specified column; Header is skipped in this case. -g <int> sort output numerically using the specified column; Header is skipped in this case. -r do reverse sorting (in combination with '-g' and '-s') -C center histogram bars (shifts x-axis by 0.5*dx) -X treat hole line as one string (single data record) -H print a data description header -V print program version and exit --version output version and copyright information --help display help -h display short help (options summary) Note: this program is not intended for use in high order numerical computations. REPORTING BUGS
Report bugs to <gnu@mirendom.net> COPYRIGHT
Copyright (C) 2003-2007, 2009, 2011 Dimitar Ivanov License: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. maphimbu 2.8.4 February 2012 MAPHIMBU(1)
All times are GMT -4. The time now is 11:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy