Sponsored Content
Special Forums UNIX and Linux Applications Script to delete few rows from a file and then update header Post 302771156 by mirwasim on Tuesday 19th of February 2013 11:36:55 PM
Old 02-20-2013
Quote:
Originally Posted by bipinajith
Try this modified code. Make necessary adjustments as per your requirement:
Code:
awk ' NR == 1 {
                HF = substr($0,1,15);
                HC = substr($0,16,6);
                HR = substr($0,22,14);
                HE = substr($0,36);
} /COOLTV/ {
                R  = $3;
                sub(/0+$/,x,R);
                HC -= 2;
                HR -= R;
                getline; next;
} !/COOLTV/ {
                print $0 > "newfile";
} END {
                printf "%s%06d%014d%d", HF, HC, HR, HE > "header";
} ' file

HDR=$( cat header )

awk -v H="$HDR" 'NR==1{ sub($0,H) }1' newfile

Hello Bipinajith
The Header file which gets created is not replacing header in newfile

when I tried separately i saw it printed value but when I did cat of file it was not appearing there
Code:
[wasim]$ HDR=$( cat header )
[wasim]$ echo $HDR
HJKL1Name00014200011800000463190664201
[wasim]$ nawk -v H="$HDR" 'NR==1{ sub($0,H) }1' check.txt
HJKL1Name00014200011800000463190664201
[wasim]$ cat check.txt
HJKL1Name00014200012000000600424618201


Last edited by mirwasim; 02-20-2013 at 01:29 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script to update header record

I am using HP UX and think this may be done with awk but bot sure. I have a file with a several header records and undeneath many detail records I need to put in the header record the number of detail records above this header record and number of detail records below this header record Header... (5 Replies)
Discussion started by: klut
5 Replies

2. Shell Programming and Scripting

How to delete particular rows from a file

Hi I have a file having 1000 rows. Now I would like to remove 10 rows from it. Plz give me the script. Eg: input file like 4 1 4500.0 1 5 1 1.0 30 6 1 1.0 4500 7 1 4.0 730 7 2 500000.0 730 8 1 785460.0 45 8 7 94255.0 30 9 1 31800.0 30 9 4 36000.0 30 10 1 15000.0 30... (5 Replies)
Discussion started by: suresh3566
5 Replies

3. Shell Programming and Scripting

delete rows in a file based on the rows of another file

I need to delete rows based on the number of lines in a different file, I have a piece of code with me working but when I merge with my C application, it doesnt work. sed '1,'\"`wc -l < /tmp/fileyyyy`\"'d' /tmp/fileA > /tmp/filexxxx Can anyone give me an alternate solution for the above (2 Replies)
Discussion started by: Muthuraj K
2 Replies

4. Shell Programming and Scripting

Script to delete a rogue header added by hacker

Hi, Someone hacked my site(s) and appended a header to every .php file in every domain. With several Word Press sites, you can imagine how many files that is! I hand edited some, but it is just a huge task to edit the thousands of files. I was a long time Linux scripter, but have not done... (5 Replies)
Discussion started by: SwankPad
5 Replies

5. Shell Programming and Scripting

Delete unique rows - optimize script

Hi all, I have the following input - the unique row key is 1st column cat file.txt A response C request C response D request C request C response E request The desired output should be C request (7 Replies)
Discussion started by: varu0612
7 Replies

6. Shell Programming and Scripting

Awk/sed script for transposing any number of rows with header row

Greetings! I have been trying to find out a way to take a CSV file with a large number of rows, and a very large number of columns (in the thousands) and convert the rows to a single column of data, where the first row is a header representing the attribute name and the subsequent series of... (3 Replies)
Discussion started by: tntelle
3 Replies

7. Shell Programming and Scripting

Manipulate all rows except header, but header should be output as well

Hello There... I have a sample input file .. number:department:amount 125:Market:125.23 126:Hardware store:434.95 127:Video store:7.45 128:Book store:14.32 129:Gasolline:16.10 I will be doing some manipulations on all the records except the header, but the header should always be... (2 Replies)
Discussion started by: juzz4fun
2 Replies

8. Shell Programming and Scripting

Script to delete rows in a file

Hi All, I am new to UNIX . Please help me in writing code to delete all records from the file where all columns after cloumn 5 in file is either 0, #MI or NULL. Initial 5 columns are string e.g. "alsod" "1FEV2" "wjwroe" " wsse" "hd3" 1 2 34 #Mi "malasl" "wses" "trwwwe" " wsse" "hd3" 1 2 0... (4 Replies)
Discussion started by: alok2082
4 Replies

9. Shell Programming and Scripting

Bash script - How to update header of scripts in one pass - multiline search/replace

Hello. A find command return a list of file. For each fileReplace the content starting with the first "§" (of two) ending with last "ɸ" (of two), regardless of the content ( five lines ) by the following content (exactly) : §2019_08_23§ # # ... (8 Replies)
Discussion started by: jcdole
8 Replies
ARDOUR(1)						      General Commands Manual							 ARDOUR(1)

NAME
ardour - a digital audio workstation SYNOPSIS
ardour -b [-U file] [session] ardour --help DESCRIPTION
Ardour is a multichannel hard disk recorder (HDR) and digital audio workstation (DAW). It is capable of simultaneous recording 24 or more channels of 32 bit audio at 48kHz. Ardour is intended to function as a "professional" HDR system, replacing dedicated hardware solutions such as the Mackie HDR, the Tascam 2424 and more traditional tape systems like the Alesis ADAT series. It is also intended to provide the same or better functionality as software systems such as ProTools, Samplitude, Logic Audio, Nuendo and Cubase VST (we acknowledge these and all other names as trademarks of their respective owners). It supports MIDI Machine Control, and so can be controlled from any MMC con- troller, such as the Mackie Digital 8 Bus mixer and many other modern digital mixers. OPTIONS
-b Print all possible keyboard binding names. -U Specify the path to the GTK RC file to use. The provided one is called ardour_ui.rc and lives in the top level Ardour source direc- tory. This file controls all color and font use within Ardour. Ardour will run without it, but its appearance is, uhm, ugly. --help Displays the help message. FILES
ardour.rc Defaults and startup settings for Ardour. ardour_ui.rc Definitions for the Ardour interface. ENVIRONMENT
ARDOUR_RC Path to ardour.rc. ARDOUR_SYSTEM_RC Path to the ardour_system.rc LADSPA_PATH Path to LADSPA plugins. BUGS
Yes. http://ardour.org/mantis is the preferred bugtracker. AUTHOR
Paul Davis. Do not contact him directly. Instead, contact him at <ardour-dev@lists.ardour.org>. You can subscribe here: http://lists.ardour.org/listinfo.cgi/ardour-dev-ardour.org 2002-12-29 ARDOUR(1)
All times are GMT -4. The time now is 05:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy