Sponsored Content
Top Forums Shell Programming and Scripting Replace a column with a value by ignoring the header lines Post 302785275 by PikK45 on Monday 25th of March 2013 07:36:54 AM
Old 03-25-2013
I guess, setting FS to , should help

Code:
gzcat ANSIAC*.gz | nawk -F"," 'NR>45{sub($3," ********",$3)}1' OFS=","

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to count lines - ignoring blank lines and commented lines

What is the command to count lines in a files, but ignore blank lines and commented lines? I have a file with 4 sections in it, and I want each section to be counted, not including the blank lines and comments... and then totalled at the end. Here is an example of what I would like my... (6 Replies)
Discussion started by: kthatch
6 Replies

2. Shell Programming and Scripting

awk/sed column replace using column header - help

$ cat log.txt Name Age Sex Lcation nfld alias xsd CC 25 M XYZ asx KK Y BB 21 F XAS awe SS N SD 21 M AQW rty SD A How can I replace the column with header "Lcation" with the column with header "alias" and delete the "alias" column? so that the final output will become: Name Age Sex... (10 Replies)
Discussion started by: jkl_jkl
10 Replies

3. UNIX for Dummies Questions & Answers

deleteing duplicate lines sing uniq while ignoring a column

I have a data set that has 4 columns, I want to know if I can delete duplicate lines while ignoring one of the columns, for example 10 chr1 ASF 30 15 chr1 ASF 20 5 chr1 ASF 30 6 chr2 EBC 15 4 chr2 EBC 30 ... I want to know if I can delete duplicate lines while ignoring column 1, so the... (5 Replies)
Discussion started by: japaneseguitars
5 Replies

4. Shell Programming and Scripting

Rename a header column by adding another column entry to the header column name URGENT!!

Hi All, I have a file example.csv which looks like this GrpID,TargetID,Signal,Avg_Num CSCH74_1_1,2007,61,256 CSCH74_1_1,212007,647,679 CSCH74_1_1,12007,3,32 CSCH74_1_1,207,299,777 I want the output as GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num CSCH74_1_1,2007,61,256... (4 Replies)
Discussion started by: Vavad
4 Replies

5. UNIX for Dummies Questions & Answers

Rename a header column by adding another column entry to the header column name

Hi All, I have a file example.csv which looks like this GrpID,TargetID,Signal,Avg_Num CSCH74_1_1,2007,61,256 CSCH74_1_1,212007,647,679 CSCH74_1_1,12007,3,32 CSCH74_1_1,207,299,777 I want the output as GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num CSCH74_1_1,2007,61,256... (1 Reply)
Discussion started by: Vavad
1 Replies

6. UNIX for Dummies Questions & Answers

Merge all csv files in one folder considering only 1 header row and ignoring header of all others

Friends, I need help with the following in UNIX. Merge all csv files in one folder considering only 1 header row and ignoring header of all other files. FYI - All files are in same format and contains same headers. Thank you (4 Replies)
Discussion started by: Shiny_Roy
4 Replies

7. Shell Programming and Scripting

Add column header and row header

Hi, I have an input like this 1 2 3 4 2 3 4 5 4 5 6 7 I would like to count the no. of columns and print a header with a prefix "Col". I would also like to count the no. of rows and print as first column with each line number with a prefix "Row" So, my output would be ... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

8. Shell Programming and Scripting

Sum of a column as new column based on header in a script

Hello, I am trying to store sum of a column as a new column inside a file but have to find the column names dynamically I/p c1,c2,c3,c4,c5 10,20,30,40,50 20,30,40,50,60 If i want to find sum only column c1, c3 and output it as c6,c7 O/p c1,c2,c3,c4,c5,c6,c7 10,20,30,40,50,30,70... (6 Replies)
Discussion started by: mkathi
6 Replies

9. UNIX for Beginners Questions & Answers

awk script to extract a column, replace one of the header and replace year(from ddmmyy to yyyy)

I have a csv which has lot of columns . I was looking for an awk script which would extract a column twice. for the first occurance the header and data needs to be intact but for the second occurance i want to replace the header name since it a duplicate and extract year value which is in ddmmyy... (10 Replies)
Discussion started by: Kunalcurious
10 Replies

10. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies
BACKTRACKER(1gmt)					       Generic Mapping Tools						 BACKTRACKER(1gmt)

NAME
backtracker - Reconstruct points, flowlines and hotspot tracks SYNOPSIS
backtracker [infile(s)] -Erotations.txt | -elon/lat/angle [ -A[young/old] ] [ -C ] [ -Df|b ] [ -Fdrift.txt ] [ -H[i][nrec] ] [ -Lf|bstep ] [ -Nupper_age ] [ -Qfixed_age ] [ -Sfilestem ] [ -Tzero_age ] [ -V ] [ -W[a|t] ] [ -:[i|o] ] [ -b[i|o][s|S|d|D[ncol]|c[var1/...]] ] [ -m[i|o][flag] ] DESCRIPTION
backtracker reads (longitude, latitude, age) positions from infiles [or standard input] and computes rotated (x,y,t) coordinates using the specified rotation parameters. It can either calculate final positions [Default] or create a sampled track (flowline or hotspot track) between the initial and final positions. The former mode allows additional data fields after the first 3 columns which must have (longi- tude,latitude,age). See option -: on how to read (latitude,longitude,age) files. No space between the option flag and the associated arguments. Use upper case for the option flags and lower case for modifiers. infile(s) Data file(s) to be projected. If not given, standard input is read. -E Give file with rotation parameters. This file must contain one record for each rotation; each record must be of the following for- mat: lon lat tstart [tstop] angle [ khat a b c d e f g df ] where tstart and tstop are in Myr and lon lat angle are in degrees. tstart and tstop are the ages of the old and young ends of a stage. If -C is set then a total reconstruction rotation is expected and tstop is implicitly set to 0 and should not be specified in the file. If a covariance matrix C for the rotation is available it must be specified in a format using the nine optional terms listed in brackets. Here, C = (g/khat)*[ a b d; b c e; d e f ] which shows C made up of three row vectors. If the degrees of free- dom (df) in fitting the rotation is 0 or not given it is set to 10000. Blank lines and records whose first column contains # will be ignored. -e Alternatively, specify the longitude, latitude, and opening angle (all in degrees and separated by /) for a single total reconstruc- tion rotation that should be applied to all input points. OPTIONS
-A Used in conjunction with -Lb|f to limit the track output to those sections whose predicted ages lie between the specified young and old limits. If -LB|F is used instead then the limits apply to the stage ids (id 1 is the youngest stage). If no limits are speci- fied then individual limits for each record are expected in columns 4 and 5 of the input file. -C Expect Total Reconstruction Rotations rather than Forward Stage Rotations [Default]. File format is similar to the stage pole for- mat except that the tstart column is not present (assumed to be 0 Ma). Requires -E. -D Set the direction to go: -Df will go backward in time (from younger to older positions), while -Db will go forward in time (from older to younger positions) [Default]. Note: For -Db you are specifying the age at the given location, whereas for -Df you are not; instead you specify the age at the reconstructed point. -F Supply a file with lon, lat, age records that contains the history of hotspot motion for the current hotspot. If given, the recon- structions will only use the 3rd data input column (i.e., the age) to obtain the location of the hotspot at that time, via an inter- polation of the hotspot motion history. This adjusted location is then used to reconstruct the point or path [No drift]. -H Input file(s) has header record(s). If used, the default number of header records is N_HEADER_RECS. Use -Hi if only input data should have header records [Default will write out header records if the input data have them]. Blank lines and lines starting with # are always skipped. -L Specify a sampled path between initial and final position: -Lf will draw particle flowlines, while -Lb will draw backtrack (hotspot track) paths. Append sampling interval in km. If step < 0 then only the rotation times will be returned. When -LF or -LB is used, the third output column will contain the stage id (1 is youngest) [Default is along-track predicted ages]. You can control the direction of the paths by using -D. -N Set the maximum age to extend the oldest stage rotation back in time [Default is no extension]. -Q Assign a fixed age to all positions. Only lon, lat input is expected [Default expects longitude, latitude, age]. Useful when the input are points defining isochrons. -S When -L is set, the tracks are normally written to stdout as a multisegment file. Specify a filestem to have each track written to filestem.#, where # is the track number. The track number is also copied to the 4th output column. -T Set the current time [Default is 0 Ma]. -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. -W Rotates the given input (lon,lat,t) and calculates the confidence ellipse for the projected point. The input point must have a time coordinate that exactly matches a particular finite rotation time, otherwise the point will be skipped. Append t or a to output time or angle, respectively, after the projected lon, lat. After these 2-3 items, we write azimuth, major, minor (in km) for the 95% confidence ellipse. See -D for the direction of rotation. -: Toggles between (longitude,latitude) and (latitude,longitude) input and/or output. [Default is (longitude,latitude)]. Append i to select input only or o to select output only. [Default affects both]. -bi Selects binary input. Append s for single precision [Default is d (double)]. Uppercase S or D will force byte-swapping. Option- ally, append ncol, the number of columns in your binary input file if it exceeds the columns needed by the program. Or append c if the input file is netCDF. Optionally, append var1/var2/... to specify the variables to be read. [Default is 3 input columns]. -bo Selects binary output. Append s for single precision [Default is d (double)]. Uppercase S or D will force byte-swapping. Option- ally, append ncol, the number of desired columns in your binary output file. [Default depends on settings]. -m Multiple segment file(s). Segments are separated by a special record. For ASCII files the first character must be flag [Default is '>']. For binary files all fields must be NaN and -b must set the number of output columns explicitly. By default the -m setting applies to both input and output. Use -mi and -mo to give separate settings to input and output. EXAMPLES
To backtrack the (x,y,t) points in the file seamounts.d to their origin (presumably the hotspot), using the DC85.d Euler poles, run backtracker seamounts.d -Db -EDC85.d > newpos.d To project flowlines forward from the (x,y,t) points stored in several 3-column, binary, double precision files, run backtracker points.* -Df -EDC85.d -Lf25 -bo -bi3 > lines.b This file can then be plotted with psxy -M. To compute the predicted Hawaiian hotspot track from 0 to 80 Ma every 1 Ma, given a history of hotspot motion file (HIdrift.txt) and a set of total reconstruction rotations for the plate (PAC_APM.d), try echo 204 19 80 | backtracker -Df -C -EPAC_APM.d -Lb1 > path.d COORDINATES
Data coordinates are assumed to be geodetic and will automatically be converted to geocentric before spherical rotations are performed. We convert back to geodetic coordinates for output. Note: If your data already are geocentric, you can avoid the conversion by using --ELLIP- SOID=sphere. SEE ALSO
GMT(1), project(1), grdrotater(1), grdspotter(1), mapproject(1), hotspotter(1), originator(1) REFERENCES
Wessel, P., 1999, "Hotspotting" tools released, EOS Trans. AGU, 80(29), p. 319. GMT 4.5.7 15 Jul 2011 BACKTRACKER(1gmt)
All times are GMT -4. The time now is 10:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy