I have to replace a field in one file with a field from other file.
I came across this awk command to replace a field with one string
nawk -F'|' -v OFS='|' '$2="replace"' temp2 > temp3
I need to have something like cut -f2 -d "|" temp1 (a field from other file) instead of 'replace'
Is... (8 Replies)
Howdy.
I know this is most likely possible using sed or awk or grep, most likely a combination of them together, but how would one go about running a grep like command on a file where you only try to match your pattern to the second field in a line, space delimited?
Example:
You are... (3 Replies)
hi
i have file as below , i want to add duplicate records like bell_bb to one record with valuve as 15 ( addition of both )
any oneline awk script to achive this ?
header 0
CAMPAIGN_NAME 1
Bell_BB 14
Bell_MONTHLY 803
SOLO_UNBEATABLE 644
Bell_BB 1
Bell_MONTHLY 25
SOLO_UNBEATABLE... (4 Replies)
i have something like this,
cat filename.txt
hui this si s"dfgdfg" omeone ipaddress="10.19.123.104" wel hope this works
i want to replace only 10.19.123.104 with different ip say 10.19.123.103
i tried this
sed -i "s/'ipaddress'/'ipaddress=10.19.123.103'/g" filename.txt
... (1 Reply)
Hi Friends,
Need Help. I have file1.txt as
File1.txt
|123|A|7267|Hyder|Cross|Sell|7801
|995|A|7051|2008|Lunar|New|Year|Promotion|7801
|996|A|7022|Q108|Targ|Prospect|&|SSCC|Savings|Promo|7801
|997|A|7182|Q1|Feb-Apr|08|Credit|ITA|PA|SBA|Campaign|7801
File2.txt... (7 Replies)
Hi,
I am trying with the below Perl command to print the first field when the second field matches the given pattern:
perl -lane 'open F, "< myfile"; for $i (<F>) {chomp $i; if ($F =~ /patt$/) {my $f = (split(" ", $i)); print "$f";}} close F' dummy_file
I know I can achieve the same with the... (7 Replies)
Hi all,
I have a requirement to replace a field with a character as per the length of the field.
Suppose i have a file where second field is of 20 character length. I want to replace second field with 20 stars (*). like ********************
As the field is not a fixed one, i want to do the... (2 Replies)
I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below:
column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10
"12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
I am trying to remove lines in the target.txt file if $5 before the - in that file matches sorted_list. I have tried grep and awk. Thank you :).
grep
grep -v -F -f targets.bed sort_list
grep -vFf sort_list targets
awk
awk -F, '
> FILENAME == ARGV {to_remove=1; next}
> ! ($5 in... (2 Replies)
Discussion started by: cmccabe
2 Replies
LEARN ABOUT NETBSD
pw_lock
PW_LOCK(3) BSD Library Functions Manual PW_LOCK(3)NAME
pw_lock, pw_mkdb, pw_abort, pw_setprefix, pw_getprefix -- passwd file update functions
LIBRARY
System Utilities Library (libutil, -lutil)
SYNOPSIS
#include <util.h>
int
pw_lock(int retries);
int
pw_mkdb(const char *username, int secureonly);
void
pw_abort(void);
int
pw_setprefix(const char *new_prefix);
const char *
pw_getprefix(void);
DESCRIPTION
The pw_lock(), pw_mkdb(), and pw_abort() functions allow a program to update the system passwd database.
The pw_lock() function attempts to lock the passwd database by creating the file /etc/ptmp, and returns the file descriptor of that file. If
retries is greater than zero, pw_lock() will try multiple times to open /etc/ptmp, waiting one second between tries. In addition to being a
lock file, /etc/ptmp will also hold the contents of the new passwd file.
The pw_mkdb() function updates the passwd file from the contents of /etc/ptmp. You should finish writing to and close the file descriptor
returned by pw_lock() before calling pw_mkdb(). If pw_mkdb() fails and you do not wish to retry, you should make sure to call pw_abort() to
clean up the lock file. If the username argument is not NULL, only database entries pertaining to the specified user will be modified. If
the secureonly argument is non-zero, only the secure database will be updated.
The pw_abort() function aborts a passwd file update by deleting /etc/ptmp. The passwd database remains unchanged.
The pw_setprefix() function defines the root directory used for passwd file updates. If the prefix is set to /newroot pw_lock() will operate
on /newroot/etc/ptmp afterwards. The default prefix is an empty string.
The pw_getprefix() function returns the root directory which is currently used for passwd file updates.
RETURN VALUES
The pw_lock() and pw_mkdb() functions return -1 if they are unable to complete properly.
FILES
/etc/master.passwd
/etc/ptmp
SEE ALSO pw_init(3), pwd_mkdb(8)BSD February 17, 2007 BSD