Sponsored Content
Top Forums Shell Programming and Scripting Replacing field based on the value of other field Post 303011075 by Corona688 on Friday 12th of January 2018 02:25:27 PM
Old 01-12-2018
Please use code tags for code. Select the text then hit the Image button.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing certain field

hi all, i am having a script file which contains lot of fields and commands. let's say i have the following word (example1) spread all over the script in every place, how can i replace it with the word (example2)?....the only way i know is to use to either delete the word (example1) and write... (1 Reply)
Discussion started by: charbel
1 Replies

2. Shell Programming and Scripting

need help with replacing a certain field...

Hi, can anyone help me? This is what i want to do....I have a string UNB+UNOA:1+OOCLIES+RTTC+080408:0358+1' and i want to replace the "1" at the end (that specific field only) to 00001 such that the new output will be like this UNB+UNOA:1+OOCLIES+RTTC+080408:0358+00001' i tried using... (5 Replies)
Discussion started by: shennanigan83
5 Replies

3. Shell Programming and Scripting

Find top N values for field X based on field Y's value

I want to find the top N entries for a certain field based on the values of another field. For example if N=3, we want the 3 best values for each entry: Entry1 ||| 100 Entry1 ||| 95 Entry1 ||| 30 Entry1 ||| 80 Entry1 ||| 50 Entry2 ||| 40 Entry2 ||| 20 Entry2 ||| 10 Entry2 ||| 50... (1 Reply)
Discussion started by: FrancoisCN
1 Replies

4. UNIX for Dummies Questions & Answers

awk - Summing a field based on another field

So, I need to do some summing. I have an Apache log file with the following as a typical line: 127.0.0.1 - frank "GET /apache_pb.gif HTTP/1.0" 200 2326 Now, what I'd like to do is a per-minute sum. So, I can have awk tell me the individual minutes, preserving the dates(since this is a... (7 Replies)
Discussion started by: treesloth
7 Replies

5. 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

6. Shell Programming and Scripting

Replacing the last field

Suppose I have a file abc.txt which contain lines:- 11.3.5.7 11.3.6.7 11.6.8.9.10 I want to replace the last field of the line to some value .I want the first line should become 11.3.5.86 .Same applies for rest lines.Please help. (6 Replies)
Discussion started by: maitree
6 Replies

7. Shell Programming and Scripting

replacing a value in a field

Hi All, I have a file yum.conf that has a field called gpgcheck this field sometimes has a value of 0 gpgcheck=0 and at other times it has a 1. I need to check the value and if it is a 1 change it to a 0 any ideas? thanks, Gartie (1 Reply)
Discussion started by: gartie
1 Replies

8. Shell Programming and Scripting

awk to update value in field based on another field

In the tab-delimeted input file below I am trying to use awk to update the value in $2 if TYPE=ins in bold, by adding the value of HRUN= in italics. In the below since in line 1 TYPE=ins the 117282541 value in $2 has 6 added because that is the value of HRUN=. Hopefully the awk is a start but I... (2 Replies)
Discussion started by: cmccabe
2 Replies

9. Shell Programming and Scripting

awk to adjust coordinates in field based on sequential numbers in another field

I am trying to output a tab-delimited result that uses the data from a tab-delimited file to combine and subtract specific lines. If $4 matches in each line then the first matching sequential $6 value is added to $2, unless the value is 1, then the original $2 is used (like in the case of line... (3 Replies)
Discussion started by: cmccabe
3 Replies

10. UNIX for Beginners Questions & Answers

Problem with getting awk to multiply a field by a value set based on condition of another field

Hi, So awk is driving me crazy on this one. I have searched everywhere and read man, docs and every related post Google can find and still no luck. The actual files I need to run this on are sensitive in nature, but it is the same thing as if I needed to calculate weighted grades for multiple... (15 Replies)
Discussion started by: cotilloe
15 Replies
PASSWD(5)						      BSD File Formats Manual							 PASSWD(5)

NAME
passwd, master.passwd -- format of the password file DESCRIPTION
The /etc/passwd file is a legacy BSD 4.3 format file. It is mostly unused, but is updated by some utility programs. Its format is similar to the /etc/master.passwd file, except that it does not contain the class, change, and expire fields described below. The /etc/master.passwd file comprises newline separated records, one per user. Each line contains ten colon (``:'') separated fields. These fields are as follows: name User's login name. password User's encrypted password. uid User's id. gid User's login group id. class User's general classification (unused). change Password change time. expire Account expiration time. gecos User's full name. home_dir User's home directory. shell User's login shell. The name field is the login used to access the computer account, and the uid field is the number associated with it. They should both be unique across the system (and often across a group of systems) since they control file access. While it is possible to have multiple entries with identical login names and/or identical user id's, it is usually a mistake to do so. Rou- tines that manipulate these files will often return only one of the multiple entries, and that one by random selection. The login name must never begin with a hyphen (``-''); also, it is strongly suggested that neither upper-case characters or dots (``.'') be part of the name, as this tends to confuse mailers. No field may contain a colon (``:'') as this has been used historically to separate the fields in the user database. The password field is the encrypted form of the password. If the password field is empty, no password will be required to gain access to the machine. This is almost invariably a mistake. Because these files contain the encrypted user passwords, they should not be readable by any- one without appropriate privileges. The group field is the group that the user will be placed in upon login. Since this system supports multiple groups (see groups(1)) this field currently has little special meaning. The class field is currently unused. The change field is the number in seconds, GMT, from the epoch, until the password for the account must be changed. This field may be left empty to turn off the password aging feature. The expire field is the number in seconds, GMT, from the epoch, until the account expires. This field may be left empty to turn off the account aging feature. The gecos field normally contains the user's full name. Note that Mac OS X differs from some other operating systems, where the gecos field may contain other comma-separcted information about the user. The home_dir field is the user's home directory. This is the full path name where the user will be placed on login. The shell field is the command interpreter the user prefers. If there is nothing in the shell field, the Bourne shell (/bin/sh) is assumed. INTERACTION WITH DIRECTORY SERVICES
Processes generally find user records using one of the getpwent(3) family of functions. On Mac OS X, these functions interact with the DirectoryService(8) daemon, which reads the /etc/master.passwd file as well as searching other directory information services to find user accounts. FILES
/etc/passwd /etc/master.passwd SEE ALSO
chpass(1), login(1), passwd(1), getpwent(3), netgroup(5), DirectoryService(8), pwd_mkdb(8), vipw(8) HISTORY
A passwd file format appeared in Version 6 AT&T UNIX. BSD
July 18, 1995 BSD
All times are GMT -4. The time now is 04:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy