Sponsored Content
Top Forums Shell Programming and Scripting AWK/Shell script for formatting data in a file Post 302640125 by rajivnairfis on Monday 14th of May 2012 07:18:36 AM
Old 05-14-2012
AWK/Shell script for formatting data in a file

Hi All,
Need an urgent help to convert a unix file in to a particular format:

**source file:**
Code:
1111111
2d2f2h2
3dfgsd3
...........
1111111   <-- repeats in every nth line. remaining all lines will be different
123ss41
432ff45
...........
1111111  <-- repetition
qwe1234
123weq3
d123451
..........


**output file**
Code:
11111112d2f2h23dfgsd3...........
1111111123ss41432ff45...........
1111111qwe1234123weq3..........

I tried something like this, but doesn't get the expected output Smilie :

Code:
bank=1111111
while read line
do
{
       echo "$line\c" >> output
}
done <"input"

sed -e 's/1111111/\
1111111/g' output > output_two


Please share ur comments

Last edited by Franklin52; 05-14-2012 at 10:48 AM.. Reason: Code tags and email address removed
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

formatting a file using shell script

Hi I have to do the following.I have to format a file test.t The contents are # Header 1231 xyz asdf asdapsdcsd //string1 = "pqrs" //string1 = "abcd"; //info //string1 = "*pqrs"; //add string1 = "#123"; //sub //string1 = "#1234567890" data = check(string1) //string1 = "#1234567890"... (12 Replies)
Discussion started by: gopsman
12 Replies

2. Shell Programming and Scripting

Awk formatting of a data file - nested for loops?

Hello - is there any way in awk I can do... 4861 x(1) y(1) z(1) 4959 x(1) y(1) z(1) 5007 x(1) y(1) z(1) 4861 x(2) y(2) z(2) 4959 x(2) y(2) z(2) 5007 x(2) y(2) z(2) 4861 x(3) y(3) z(3) 4959 x(3) y(3) z(3) 5007 x(3) y(3) z(3) to become... 4861 x(1) y(1) z(1) 4861 x(2) y(2) z(2)... (3 Replies)
Discussion started by: catwoman
3 Replies

3. Shell Programming and Scripting

formatting data file with awk or sed

Hi, I have a (quite large) data file which looks like: _____________ header part.. more header part.. x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 ... ... x59 x60 y1 y2 y3 y4... ... y100 ______________ where x1, x2,...,x60 and y1, y2,...y100 are numbers of 10 digits (so each line... (5 Replies)
Discussion started by: lego
5 Replies

4. Shell Programming and Scripting

Formatting the text file using shell script

How to add the filename to end of each line with | as seperator, except first and last line of the file(s) in directories(with diff tree structure) using shell script?. And also how to replace a list of strings with another set of strings, which is present in a file?. Kindly help out on... (1 Reply)
Discussion started by: av_vinay
1 Replies

5. Shell Programming and Scripting

Formatting a file using shell script

I have a file with contents something similar to as below : SVCNAME,12m-1a,1a-2a,2a-3a,3a-4a,5a-6a,6a-7a,7a-8a,8a-9a,9a-10a,10a-11a,11a-12n,12n-1p,13p-14p,14p-15p,15p-16p,16p-17p,17p-18p,18p-19p,19p-20p,20p-21p,21p-22p,22p-23p,11p-12m, TOTALS... (5 Replies)
Discussion started by: deo_kaustubh
5 Replies

6. Shell Programming and Scripting

Shell Script Problems, Lose formatting when copy pasting from formatted file.

Hello, I'm having trouble with formatting some text via the terminal. I can get it perfectly formatted, but when I try and copy paste the text from the output file it loses it's formatting. Very frustrating! Basically I have 7 files (data data2 data3 data4 data5 data6 data7) containing a... (13 Replies)
Discussion started by: facetoe
13 Replies

7. Shell Programming and Scripting

Formatting File Using Shell Script

Hi Team, We have a requirement where we need to format input file using shell script by meeting the below conditions. 1. 1. Ignore first 549 characters of that file. 2. 2. After that we need to make a file of 100 characters per line, repeat it until the 3rd ... (16 Replies)
Discussion started by: ataneja7
16 Replies

8. Shell Programming and Scripting

Formatting a file using shell script

Hi, Please find the below lines of a file B1/OT "GIB10" 837 130308 1351 MONORONOUS DIGI PATH FAULT SUPER B1/OT "GIB10" 520 130418 1537 MONORONOUS DIGI PATH FAULT SUPER B1/XT "GIB10" 762 130421 0653 TV Y-CEIVER ADMIN RXOCF-62 241_OKEBOLE_NEW 1 B1/XT "GIB10" 385 130425 1931 TV Y-CEIVER... (2 Replies)
Discussion started by: Ardhendu
2 Replies

9. Shell Programming and Scripting

Data formatting using awk

Need assistance on the data extraction using awk Below is the format and would like to extract the data in another format ------------------------------------------------------------------------------------------------- Minimum Temperature (deg F ) DAY 1 2 3 4 5 6 7 8 9 10 11... (4 Replies)
Discussion started by: ajayram_arya
4 Replies

10. UNIX for Advanced & Expert Users

Need Optimization shell/awk script to aggreagte (sum) for all the columns of Huge data file

Optimization shell/awk script to aggregate (sum) for all the columns of Huge data file File delimiter "|" Need to have Sum of all columns, with column number : aggregation (summation) for each column File not having the header Like below - Column 1 "Total Column 2 : "Total ... ...... (2 Replies)
Discussion started by: kartikirans
2 Replies
convert(1)						      General Commands Manual							convert(1)

NAME
convert - convert an audio file SYNOPSIS
[source_file] [target_file] [] [] [] [] [] [] [] DESCRIPTION
This command converts audio files from one supported file format, data format, sampling rate, and number of channels to another. The unconverted file is retained as a source file. are the file formats for the source and destination files. Each format can be one of these: Sun file format NeXT file format Microsoft RIFF Waveform file format MuLaw format ALaw linear 16-bit format offset (unsigned) linear 8-bit format linear 8-bit format If you omit uses the header or filename extension in the source file. You can omit if you supply a filename extension for the des- tination file. is the data type for the destination files. data_type can be one of these: MuLaw ALaw linear 16-bit offset (unsigned) linear 8-bit data linear 8-bit data If you omit uses an appropriate data type, normally the data type of the source file. are the number of samples per second for the source and destination file. Typical sampling rates range from 8 to 11k (for voice quality) to 44,100 (for CD quality). You can use to indi- cate thousands. For example, means 8,000 samples per second. If you omit uses a rate defined by the source file header or its filename extension. For a raw file with no extension, 8,000 is used. By playing the file, you can determine if 8,000 samples is too fast or too slow. If you omit uses a sampling rate appropriate for the destination file format; if possible, it matches the sampling rate of the source file. are the number of channels in the source and destination files. Use for mono; for stereo. If is omitted, uses the information in the header; for raw data files, it uses mono. If is omitted, matches what was used for the source file (through the header or option); for raw data files, it uses mono. EXAMPLES
Convert a raw data file to a headered file. Convert a raw data file to a headered file when the source has no extension, was sampled at 11,025 per second, and has stereo data. To save disk space, convert an audio file with CD quality sound to voice quality sound. AUTHOR
was developed by HP. Sun is a trademark of Sun MicroSystems, Inc. NeXT is a trademark of NeXT Computers, Inc. Microsoft is a trademark of Microsoft Corporation. SEE ALSO
audio(5), asecure(1M), aserver(1M), attributes(1), send_sound(1). convert(1)
All times are GMT -4. The time now is 06:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy