Sponsored Content
Top Forums Shell Programming and Scripting awk or sed to format text file Post 302484030 by posner on Wednesday 29th of December 2010 11:10:25 AM
Old 12-29-2010
Thanks Guru,

UR script almost works but i have some issue when i extended the file little

Code:
01
02
7now
abc Top 40
music
Kidz Only!
MC 851
MC 852
MC 853
7NOW
Arch_Diac
xyz2
abc
h211
Commacc1
Commacc2
Commacc3
5 max
5 max HD
@MAX
@MAX HD
Action MA
08
09
10
7now
BBC World News
MC9
Mexicana
Singers and Standard
11
7NOW
Commacc1
Commacc2
22
7NOW
13
11
7NOW
5 MAX HD
5 MAX HD
BET ON

the output i got is

Code:
./f1.pl test.txt 
01 
02 
now7
abc Top 40
music
Kidz Only!
MC 851
MC 852
MC 853
NOW7
Arch_Diac
xyz2
abc
h211
Commacc1
Commacc2
Commacc3
max 5
max HD 5
@MAX
@MAX HD
Action MA
08 
09 
10 
now7
BBC World News 
MC9
Mexicana
Singers and Standard
11 
7NOW                  # this is not getting changed for some reason 
Commacc1 
Commacc2 
22
NOW7
13
11
NOW7
MAX HD 5
MAX HD 5
BET ON

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk or sed to add field in a text file

Hi there, I have a csv file with some columns comma sepated like this : 4502-17,PETER,ITA2,LEGUE,92,ME - HALF,23/05/10 15:00 4502-18,CARL,ITA2,LEGUE,96,ME - HALF,20/01/09 14:00 4502-19,OTTO,ITA2,LEGUE,97,ME - MARY,23/05/10 15:00 As you can see the column n. 7 is a timestamp column, I need... (23 Replies)
Discussion started by: capnino
23 Replies

2. Programming

awk script to convert a text file into csv format

hi...... thanks for allowing me to start a discussion i am collecting usb usage details of all users and convert it into csv files so that i can export it into some database.. the input text file is as follows:- USB History Dump by nabiy (c)2008 (1) --- Kingston DataTraveler 130 USB... (2 Replies)
Discussion started by: certteam
2 Replies

3. Shell Programming and Scripting

Joining lines in a text file using AWK or SED

Hi All I'm struggling a bit here :( I need a way of joining lines contained in a text file. I've seen numerous SED and AWK examples and none of them seem to be working for me. The text file has 4 lines: DELL1427 DOC 30189342 79 Now bear with me on this one as I'm actually... (4 Replies)
Discussion started by: huskie69
4 Replies

4. Shell Programming and Scripting

Need awk/sed to format a file

My content of source file is as below scr1 a1 scr2 a2 b2 scr3 a3 b3 c3 I need a awk/sed command (to be used in C shell)to format it to something like below scr1 $a1 >file1 scr2 $a2 $b2 >file2 scr3 $a3 $b3 $c3 >file3 (12 Replies)
Discussion started by: animesharma
12 Replies

5. Shell Programming and Scripting

using sed/awk to replace a block of text in a file?

My apologies if this has been answered in a previous post. I've been doing a lot of searching, but I haven't been able to find what I was looking for. Specifically, I am wondering if I can utilize sed and/or awk to locate two strings in a file, and replace everything between those two strings... (12 Replies)
Discussion started by: kiddsupreme
12 Replies

6. UNIX for Dummies Questions & Answers

Inserting text into a file with awk or sed

Hello, I've been trying to get a script working that fetches weather-data and converts it into an .ics file. The script works so far put I'm stuck at the point where I need to add specific static data. A thorough search through the forum did not point me into the right direction. #!/bin/bash... (3 Replies)
Discussion started by: Schubi
3 Replies

7. Shell Programming and Scripting

Help with awk statement to format text file.

Hello, I am fairly new to shellscripting and have written a script to check on messages file and report failed logins: Here is the original file: Jul 17 03:38:07 sfldmilx086 sshd: error: PAM: Authentication failure for houghn97 from 10.135.77.201 Jul 17 03:38:07 sfldmilx086 sshd: error:... (2 Replies)
Discussion started by: neilh1704
2 Replies

8. Shell Programming and Scripting

Help on Log File format using sed or awk

Hello Gurus, First, i would like to know is there any way to solve my problem. i have a log file like this: INFO - ABCDRequest :: processing started for the record <0> TransactionNo <Txn#1> recordID <recID#1> INFO - ABCDRequest :: processing started for the record <0> TransactionNo... (9 Replies)
Discussion started by: VasuKukkapalli
9 Replies

9. Shell Programming and Scripting

Datestamp format 2nd change in csv file (awk or sed)

I have a csv file formatted like this: 2014-08-21 18:06:26,A,B,12345,123,C,1232,26/08/14 18:07and I'm trying to change it to MM/DD/YYYY HH:MM for both occurances. I have got this: awk -F, 'NR <=1 {print;next}{"date +%d/%m/%Y\" \"%H:%m -d\""$1 "\""| getline dte;$1=dte}1' OFS="," test.csvThis... (6 Replies)
Discussion started by: say170
6 Replies

10. Shell Programming and Scripting

Format the text using sed or awk

I was able to figure out how to format a text. Raw Data: $ cat test Thu Aug 23 15:43:28 UTC 2018, hostname01, 232.02, 3, 0.00 Thu Aug 23 15:43:35 UTC 2018, hostname02, 231.09, 4, 0.31 Thu Aug 23 15:43:37 UTC 2018, hostname03, 241.67, 4, 0.43 (5 Replies)
Discussion started by: kenshinhimura
5 Replies
mlib_VectorMaximum_U8(3MLIB)				    mediaLib Library Functions				      mlib_VectorMaximum_U8(3MLIB)

NAME
mlib_VectorMaximum_U8, mlib_VectorMaximum_S8, mlib_VectorMaximum_S16, mlib_VectorMaximum_S32, mlib_VectorMaximum_F32, mlib_VectorMaxi- mum_D64 - find the maximum value in a vector SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_VectorMaximum_U8(mlib_u8 *max, const mlib_u8 *x, mlib_s32 n); mlib_status mlib_VectorMaximum_S8(mlib_s8 *max, const mlib_s8 *x, mlib_s32 n); mlib_status mlib_VectorMaximum_S16(mlib_s16 *max, const mlib_s16 *x, mlib_s32 n); mlib_status mlib_VectorMaximum_S32(mlib_s32 *max, const mlib_s32 *x, mlib_s32 n); mlib_status mlib_VectorMaximum_F32(mlib_f32 *max, const mlib_f32 *x, mlib_s32 n); mlib_status mlib_VectorMaximum_D64(mlib_d64 *max, const mlib_d64 *x, mlib_s32 n); DESCRIPTION
Each of these functions finds the maximum value of all elements in a vector. The following equation is used: max[0] = MAX{ x[i] i = 0, 1, ..., (n - 1) } PARAMETERS
Each of the functions takes the following arguments: max Pointer to the maximum value. x Pointer to the first element of the source vector. n Number of elements in the source vector. RETURN VALUES
Each of the functions returns MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mlib_VectorMinimum_U8(3MLIB), mlib_MatrixMaximum_U8(3MLIB), mlib_MatrixMinimum_U8(3MLIB), attributes(5) SunOS 5.10 10 Nov 2004 mlib_VectorMaximum_U8(3MLIB)
All times are GMT -4. The time now is 02:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy