for the command below, it looks for the 3rd field value matching "P" and printing it.
awk '{if ($3 == "P") print}' file
how would i express this if i use a loop to find more that 1 variable fro a list? this doesn't seem to work...
cat list | while read n
do
awk '{if ($3 == "$n") print}'... (1 Reply)
guys,
I'm trying to 9k lines of the following:
aaa aaa 1 1 1
to
aaa aaa 1 01 1
Im pretty ignorant when it comes to subtituting fields using awk
any help ?
Tony (1 Reply)
I created a file contains:
create table .....;
create index ....;
create trigger...;
and I want to substitue from my file ; by ;-- from the line where appears create trigger to the end of the file and keep intact the create table step and index in the file.
awk '/CREATE... (2 Replies)
Hi again.
A have a CSV-file in the following format:
2008.09.01,15:17:42,9227096485,9233175320,CTC10,SMS,0901151742098314,Target_MSIS
DN_is_blacklisted
I want to have an awk command that will say:
If the first 3 digits of $4 does not begin with 922 or 923, then make $8 say "Invalid... (3 Replies)
Hello,
I have a file containing lines such as:
(1 104 (16) (17) (18) (102))$
(1 105 (16) (17) (19:21) (102))$
I would like to extract the numbers, only by using awk (or gawk).
I do not want to use "sed" as it is very slow.
For now my solution consists in... (2 Replies)
I am trying to use AWK to replace dallinux02 to dallinux03 everywhere in the servers.txt file and move it over to "awk2".
Here is my script "awk2.awk":
gsub(/dallinux02/, "dallinux03"); print > "awk2"
I am trying to run this using the following:
$ awk -f awk2.awk... (3 Replies)
Hi,
I have a variable to be substituted in awk. I am using AIX 5.3. Here is my piece of code:
REPL_DT=`date +'%Y\\\\\\\\\/%m\\\\\\\\\/%d'`
NEW_LINE=$(echo $Line | awk '{sub ($4, '$REPL_DT'); printf "# %-7s %9s %18s\n", $2,$3,$4}')
sed $n" s/.*/$NEW_LINE/" kfile > tmp
mv tmp kfile
Here,... (2 Replies)
Hi,
here's my - not so easy to describe - problem: I want to compare the values of one file (FileA) with a cutoff-value and, if this comparison is true, substitute those values with those in the second file (FileB). However, there are many FileA's (FileA), whereas there is only one FileB. Every... (10 Replies)
Hi all,
I need some help with substitution in awk.
Is it possible to substitute field from awk output with string from file?
For example:
zcat /SMS/CDR/cdr_TC/callLogs*_*_2013092710*.gz | sed 's/:/;/g' | awk -F";" '{if($2==1 && $10~/389123456789/) print $36";"$37}'
2;19733248
I want... (6 Replies)
Can I specify a default value to a variable in AWK like BASH in one statement using parameter substitution?
BASH example:
argument=${$1-"default if empty"} (BASH)
I know I can do:
argument=$1; sub ( "^$", "default if empty", argument) (AWK)
Mike (13 Replies)
Discussion started by: Michael Stora
13 Replies
LEARN ABOUT LINUX
chfn
CHFN(1) User Commands CHFN(1)NAME
chfn - change real user name and information
SYNOPSIS
chfn [-f full_name] [-r room_no] [-w work_ph] [-h home_ph] [-o other] [user]
DESCRIPTION
The chfn command changes user fullname, office number, office extension, and home phone number information for a user's account. This
information is typically printed by finger(1) and similar programs. A normal user may only change the fields for her own account, subject
to the restrictions in /etc/login.defs. (The default configuration is to prevent users from changing their fullname.) The superuser may
change any field for any account. Additionally, only the superuser may use the -o option to change the undefined portions of the GECOS
field.
These fields must not contain any colons. Except for the other field, they should not contain any comma or equal sign. It is also
recommended to avoid non-US-ASCII characters, but this is only enforced for the phone numbers. The other field is used to store accounting
information used by other applications.
If none of the options are selected, chfn operates in an interactive fashion, prompting the user with the current values for all of the
fields. Enter the new value to change the field, or leave the line blank to use the current value. The current value is displayed between a
pair of [ ] marks. Without options, chfn prompts for the current user account.
CONFIGURATION
The following configuration variables in /etc/login.defs change the behavior of this tool:
CHFN_RESTRICT (string)
This parameter specifies which values in the gecos field of the /etc/passwd file may be changed by regular users using the chfn
program. It can be any combination of letters f, r, w, h, for Full name, Room number, Work phone, and Home phone, respectively. For
backward compatibility, yes is equivalent to rwh and no is equivalent to frwh. If not specified, only the superuser can make any
changes. The most restrictive setting is better achieved by not installing chfn SUID.
FILES
/etc/login.defs
Shadow password suite configuration.
/etc/passwd
User account information.
SEE ALSO chsh(1), login.defs(5), passwd(5).
User Commands 06/24/2011 CHFN(1)