Sponsored Content
Top Forums Shell Programming and Scripting Supressing and replacing the output of a field in Awk Post 302278877 by Glyn_Mo on Wednesday 21st of January 2009 10:47:45 AM
Old 01-21-2009
Quote:
Originally Posted by zaxxon
Not sure if it is what yo want:

Code:
awk 'NR > 1 && /linger/ {sub(/\(linger: 1800\)/,"ChangeBase"); print; next} NR > 1 {print $0,"CMBase"; next} {print}' infile
User Process ID Time Active Licences Type
ChangeAdmin (Phys-agsdev/19353 212), start Wed 1/21 6:30 ChangeBase
u414013 (Phys-agsdev/19353 1491), start Wed 1/21 12:54 ChangeBase
z001429 (Phys-agsdev/19353 788), start Wed 1/21 13:03 ChangeBase
u414014 (Phys-agsdev/19353 1009), start Wed 1/21 10:34 CMBase
z311203 (Phys-agsdev/19353 2368), start Wed 1/21 10:52 CMBase
u414020 (Phys-agsdev/19353 879), start Wed 1/21 11:43 CMBase
z311260 (Phys-agsdev/19353 1523), start Wed 1/21 12:17 CMBase
oracled (Phys-agsdev/19353 555), start Wed 1/21 9:00 CMBase
u414013 (Phys-agsdev/19353 1717), start Wed 1/21 12:56  CMBase

Comes back with an error:

nawk: syntax error at source line 39
context is
NR > 1 && /linger/ >>> { <<< sub(/\(linger: 1800\)/,"ChangeBase"); print; next} NR > 1 {print $0,"CMBase"; next} {print}' infile
nawk: illegal statement at source line 39

I can't see anything wrong with it?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to include field in the output filename of awk

Im using awk and I want the output filename to contain the first field of the input file. Ex. 1 dddd wwwww 1 eeeee wwww 1 wwww eerrrr 2 eeee eeeeee I want the output files to be xxx1 and xxx2 Thank you (4 Replies)
Discussion started by: yahyaaa
4 Replies

2. Shell Programming and Scripting

Help supressing spool output from screen when calling sqlplus from script

I'm calling an embedded sql from my shell script file. This sql does simple task of spooling out the contents of the table (see below my sample code) into a spool file that I specify. So far so good, but the problem is that the output is also displayed on screen which I do NOT want. How can I... (3 Replies)
Discussion started by: MxC
3 Replies

3. Shell Programming and Scripting

Help with Awk finding and replacing a field based on a condition

Hi everybody, I'm trying to replace the $98 field with "T" if the last field (108th) is T I've tried awk 'BEGIN{OFS=FS="|"} {if ($108=="T")sub($98,"T"); print}' test.txt but that doesn't do anything also tried awk 'BEGIN{OFS=FS="|"}{ /*T.$/ sub($98,"T")} { print}' test.txt but... (2 Replies)
Discussion started by: jghi123
2 Replies

4. Shell Programming and Scripting

awk output field delimiter

Dear All, 1.txt (tab in between each value in a line) a b c a b c a c d you can see below, why with ~ i can output with tab, but = cannot? # awk -F'\t' '$2 ~ /b/' 1 a b c a b c # awk -F'\t' '$2 = "b"' 1 a b c a b c a b d ... (1 Reply)
Discussion started by: jimmy_y
1 Replies

5. Shell Programming and Scripting

Compare two files and output difference, by first field using awk.

It seems like a common task, but I haven't been able to find the solution. vitallog.txt 1310,John,Hancock 13211,Steven,Mills 122,Jane,Doe 138,Thoms,Doe 1500,Micheal,May vitalinfo.txt 12122,Jane,Thomas 122,Janes,Does 123,Paul,Kite **OUTPUT** vitalfiltered.txt 12122,Jane,Thomas... (2 Replies)
Discussion started by: charles33
2 Replies

6. UNIX for Dummies Questions & Answers

awk - output field separator

In awk, how do I print all fields with a specified output field separator? I have tried the following, which does not print the output FS: echo a b c d | awk 'BEGIN{OFS = ";"}{print $0}' (3 Replies)
Discussion started by: locoroco
3 Replies

7. UNIX for Dummies Questions & Answers

awk truncating first field output?

Hello, I'm writing an Awk script to take a command line argument (student's name) and output their relevant student#, name, and marks. For some reason, awk arbitrarily removes the first digit from the student number and doesn't show me the proper output. Here is my code: #! /usr/bin/awk -f... (6 Replies)
Discussion started by: trashmouth12
6 Replies

8. Shell Programming and Scripting

awk calculation wrong field output

The awk below is close but I can't seem to fix it to produce the desired output. Thank you :). current awk with output awk '{c1++; c2+=($2)} END{for (e in c1) print e, c1, c2}' input EFCAB5 2 50 USH2A 2 19 desired... (8 Replies)
Discussion started by: cmccabe
8 Replies

9. Shell Programming and Scripting

awk to print field from lookup file in output

The below awk uses $3 and $4 in search as the min and max, then takes each $2 value in lookup and compares it. If the value in lookupfalls within the range in searchthen it prints the entire line in lookup/ICODE]. What I can't seem to figure out is how to print the matching $5 from search on that... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. Shell Programming and Scripting

Using awk to print output based on first field.

Hi Folks, I have one requirement, There is one file, which contains two fields. Based on first field, I need to print an output. Example will be more suitable. Input file like this. abc 5 abc 10 xyz 6 xyz 9 xyz 10 mnp 10 mnp 12 mnp 6 (2 Replies)
Discussion started by: Raza Ali
2 Replies
mp2(1)																	    mp2(1)

NAME
mp2 - Moller-Plesset Perburbation Theory DESCRIPTION
The module determines the second-order Moller-Plesset energy and one-particle density matrix (OPDM) for RHF, UHF, and ROHF (using semi- canonical orbitals) references. Frozen orbitals can be used when computing the energy but not the OPDM. REFERENCES
Original Moller-Plesset paper: 1. C. Moller and M. S. Plesset, "Note on an Approximation Treatment for Many-Electron Systems," Phys. Rev. 46, 618 (1934). Open-Shell Perturbation Theory 1. T. D. Crawford, H. F. Schaefer, and T. J. Lee, "On the energy invariance of open-shell perturbation theory with respect to unitary transformations of molecular orbitals," J. Chem. Phys. 105, 1060 (1996). MP(2) Gradient Theory: 1. M. Frisch, M. Head-Gordon, and J. Pople, "A Direct MP2 Gradient Method," Chem. Phys. Lett. 166, 275 (1990). 2. I. Nielsen, "A new direct MP2 gradient algorithm with implementation on a massively parallel computer," Chem. Phys. Lett. 255, 210 (1996). INPUT FORMAT
Input for this program is read from the file input.dat. The following keywords are valid: WFN = string Specifies the type of wave function desired. The only valid entry at the present is MP2. There is no default. REFERENCE = string Specifies the type of orbitals used for the single-determinant reference function. Valid entries include RHF, UHF, and ROHF. There is no default. PRINT = integer Determines the verbosity of the output. A value of 0 (the default) specifies minimal printing. CACHETYPE= string Selects the priority type for maintaining the automatic memory cache used by the DPD codes. (See libdpd.html for further details.) A value of LOW (the default) selects a "low priority" scheme in which the deletion of items from the cache is based on pre-pro- grammed priorities. A value of LRU selects a "least recently used" scheme in which the oldest item in the cache will be the first one deleted. CACHELEV= integer Selects the level of automatic cacheing desired in the storage of various amplitudes, integrals, and intermediates in the coupled cluster procedure. A value of 0 retains no quantities in cache, while a level of 6 attempts to store all quantities in cache. For particularly large calculations, a value of 0 may help with certain types of memory problems. The default is 2, which means that all four-index quantites with up to two virtual-orbital indices (e.g., <ij|ab> integrals) may be held in the cache. OPDM = boolean If TRUE calculate the one-particle density matrix and make OPDM_WRITE default to TRUE. The default value of OPDM is FALSE. OPDM_WRITE = boolean Flag for whether or not to write the one-particle density matrix to disk. OPDM_PRINT = boolean Flag for whether or not to print the one-particle density matrix. 10 August, 2003 mp2(1)
All times are GMT -4. The time now is 02:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy