Sponsored Content
Top Forums Shell Programming and Scripting How to replace a specific word in specific column? Post 302295273 by radoulov on Saturday 7th of March 2009 07:30:25 AM
Old 03-07-2009
Actually it could be less verbose and the previous code won't work if you have a location named 0 or "" (null string), this one should handle those cases too:
Code:
awk -F'\t' 'NR == FNR { ref[$1] = $2; next }
($2 in ref && $4 = ref[$2]) || 1
' OFS='\t' reffile mainfile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to cut first line only from a text near a specific column without cutting a word

First I have to say thank you to this community and this forum. You helped me very much builing several useful scripts. Now, I can't get a solution the following problem, I'm stuck somehow. Maybe someone has an idea. In short, I dump a site via lynx and pipe the output in a file. I need to... (7 Replies)
Discussion started by: lowmaster
7 Replies

2. UNIX for Dummies Questions & Answers

How to print line starts with specific word and contains specific word using sed?

Hi, I have gone through may posts and dint find exact solution for my requirement. I have file which consists below data and same file have lot of other data. <MAPPING DESCRIPTION ='' ISVALID ='YES' NAME='m_TASK_UPDATE' OBJECTVERSION ='1'> <MAPPING DESCRIPTION ='' ISVALID ='NO'... (11 Replies)
Discussion started by: tmalik79
11 Replies

3. Shell Programming and Scripting

Help with replace column data with specific word

Input file: Populus_trichocarpa 30 0 50 0 0 US Vitis_vinifera 1 18 2 8 6 US Populus_trichocarpa 1 5 100 0 0 US Arabidopsis_lyrata_subsp._lyrata 0 90 0 0 0 US Glycine_max 0 2 3 0 70 UK Desired output file: Populus_trichocarpa YES NO YES NO NO US Vitis_vinifera YES YES YES YES YES US... (4 Replies)
Discussion started by: perl_beginner
4 Replies

4. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

5. Shell Programming and Scripting

Using sed to replace a word at specific location

I'm try to change a the prohibit to aix for the lines starting with ssh and emagent and rest should be the same. Can anyone please suggest me how to do that using a shell script or sed passwd account required /usr/lib/security/pam_prohibit passwd session required ... (13 Replies)
Discussion started by: pjeedu2247
13 Replies

6. UNIX for Dummies Questions & Answers

Quick UNIX command to display specific lines in the middle of a file from/to specific word

This could be a really dummy question. I have a log text file. What unix command to extract line from specific string to another specific string. Is it something similar to?: more +/"string" file_name Thanks (4 Replies)
Discussion started by: aku
4 Replies

7. Shell Programming and Scripting

How to print multiple specific column after a specific word?

Hello.... Pls help me (and sorry my english) :) So I have a file (test.txt) with 1 long line.... for example: isgc jsfh udgf osff 8462 error iwzr 653 idchisfb isfbisfb sihfjfeb isfhsi gcz eifh How to print after the "error" word the 2nd 4th 5th and 7th word?? output well be: 653 isfbisfb... (2 Replies)
Discussion started by: marvinandco
2 Replies

8. Shell Programming and Scripting

Replace a specific column with a specific value

Hi, I am looking to replacing value of a specific column of /etc/pam.d/system-auth file. My file looks like this password sufficient pam_unix.so md5 shadow nullok try_first_pass use_authtok expected result password sufficient pam_unix.so md5 shadow nullok try_first_pass use_authtok... (5 Replies)
Discussion started by: Litu1988
5 Replies

9. Shell Programming and Scripting

Overwrite specific column in xml file with the specific column from adjacent line

I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file. Here is the file. <!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
Discussion started by: rk4k
2 Replies

10. Shell Programming and Scripting

Replace specific column delimiter

Hi All, I have a file with a pipe delimiter. I need to replace the delimiter with html tags. I managed to get all the delimiters replaced along with first and last but the requirement is that I need to change 7th delimiter with slight change. File1: ... (2 Replies)
Discussion started by: shash
2 Replies
ADCLI(8)							  System Commands							  ADCLI(8)

NAME
adcli - Tool for performing actions on an Active Directory domain SYNOPSIS
adcli info domain.example.com adcli join domain.example.com adcli create-user [--domain=domain.example.com] user adcli delete-user [--domain=domain.example.com] user adcli create-group [--domain=domain.example.com] user adcli delete-group [--domain=domain.example.com] user adcli add-member [--domain=domain.example.com] group user... adcli remove-member [--domain=domain.example.com] group user... adcli preset-computer [--domain=domain.example.com] computer... adcli reset-computer [--domain=domain.example.com] computer adcli delete-computer [--domain=domain.example.com] computer GENERAL OVERVIEW
adcli is a command line tool that can perform actions in an Active Directory domain. Among other things it can be used to join a computer to a domain. See the various sub commands below. The following global options can be used: -D, --domain=domain The domain to connect to. If a domain is not specified then the domain part of the local computer's host name is used. -R, --domain-realm=REALM Kerberos realm for the domain. If not specified then the upper cased domain name is used. -S, --domain-controller=server Connect to a specific domain controller. If not specified then an appropriate domain controller is automatically discovered. -C, --login-ccache=/path/to/file Use the specified kerberos credential cache to authenticate with the domain. -U, --login-user=User Use the specified user account to authenticate with the domain. If not specified then the name 'Administrator' will be used. --no-password Don't show prompts for or read a password from input. -W, --prompt-password Prompt for a password if necessary. This is the default. --stdin-password Read a password from stdin input instead of prompting for a password. -v, --verbose Run in verbose mode with debug output. QUERYING DOMAIN INFORMATION
adcli info displays discovered information about an Active Directory domain or an Active Directory domain controller. $ adcli info domain.example.com ... $ adcli info --domain-controller=dc.domain.example.com ... adcli info will output as much information as it can about the domain. The information is designed to be both machine and human readable. The command will exit with a non-zero exit code if the domain does note exist or cannot be reached. To show domain info for a specific domain controller use the --domain-controller option to specify which domain controller to query. Use the --verbose option to show details of how the domain is discovered and queried. Many of the global options, in particular authentication options, are not usable with the adcli info command. JOINING THE LOCAL MACHINE TO A DOMAIN
adcli join creates a computer account in the domain for the local machine, and sets up a keytab for the machine. It does not configure an authentication service (such as sssd). $ adcli join domain.example.com Password for Administrator: In addition to the global options, you can specify the following options to control how this operation is done. -N, --computer-name=computer The short non-dotted name of the computer account that will be created in the domain. If not specified then the first portion of the --host-fqdn is used. -O, --domain-ou=OU=xxx The full distinguished name of the OU in which to create the computer account. If not specified then the computer account will be created in a default location. -H, --host-fqdn=host Override the local machine's fully qualified domain name. If not specified the local machine's hostname will be retrieved via gethostname(). -K, --host-keytab=/path/to/keytab Specify the path to the host keytab where host credentials will be written after a successful join operation. If not specified the default location will be used, usually /etc/krb5.keytab. --login-type={computer|user} Specify the type of authentication that will be performed before creating the machine account in the domain. If set to 'computer' then the computer must already have a preset account in the domain. If not specified and none of the other --login-xxx arguments have been specified, then will try both 'computer' and 'user' authentication. --os-name=name Set the operating system name on the computer account. The default depends on where adcli was built, but is usually something like 'linux-gnu'. --os-service-pack=pack Set the operating system service pack on the computer account. Not set by default. --os-version=version Set the operating system version on the computer account. Not set by default. --service-name=service Additional service name for a kerberos principal to be created on the computer account. This option may be specified multiple times. --user-principal=host/name@REALM Set the userPrincipalName field of the computer account to this kerberos principal. If you omit the value for this option, then a principal will be set in the form of host/host.example.com@REALM --one-time-password Specify a one time password for a preset computer account. This is equivalent to using --login-type=computer and providing a password as input. --show-details After a successful join print out information about join operation. This is output in a format that should be both human and machine readable. --show-password After a successful join print out the computer machine account password. This is output in a format that should be both human and machine readable. CREATING A USER
adcli create-user creates a new user account in the domain. $ adcli create-user Fry --domain=domain.example.com --display-name="Philip J. Fry" --mail=fry@domain.example.com In addition to the global options, you can specify the following options to control how the user is created. --display-name="Name" Set the displayName attribute of the new created user account. -O, --domain-ou=OU=xxx The full distinguished name of the OU in which to create the user account. If not specified then the computer account will be created in a default location. --mail=email@domain.com Set the mail attribute of the new created user account. This attribute may be specified multiple times. --unix-home=/home/user Set the unixHomeDirectory attribute of the new created user account, which should be an absolute path to the user's home directory. --unix-gid=111 Set the gidNumber attribute of the new created user account, which should be the user's numeric primary group id. --unix-shell=/bin/shell Set the pos attribute of the new created user account, which should be the user's numeric primary user id. --unix-uid=111 Set the loginShell attribute of the new created user account, which should be a path to a valid shell. DELETING A USER
adcli delete-user deletes a user account from the domain. $ adcli delete-user Fry --domain=domain.example.com The various global options can be used. CREATING A GROUP
adcli create-group creates a new group in the domain. $ adcli create-group Pilots --domain=domain.example.com --description="Group for all pilots" In addition to the global options, you can specify the following options to control how the group is created. --description="text" Set the description attribute of the new created group. -O, --domain-ou=OU=xxx The full distinguished name of the OU in which to create the group. If not specified then the computer account will be created in a default location. DELETING A GROUP
adcli delete-group deletes a group from the domain. $ adcli delete-group Pilots --domain=domain.example.com The various global options can be used. ADDING A MEMBER TO A GROUP
adcli add-member adds one or more users to a group in the domain. The group is specified first, and then the various users to be added. $ adcli add-member --domain=domain.example.com Pilots Leela Scruffy The various global options can be used. REMOVING A MEMBER FROM A GROUP
adcli remove-member removes a user from a group in the domain. The group is specified first, and then the various users to be removed. $ adcli remove-member --domain=domain.example.com Pilots Scruffy The various global options can be used. PRESET COMPUTER ACCOUNTS
adcli preset-computer pre-creates one or more computer accounts in the domain for machines to later use when joining the domain. By doing this machines can join using a one time password or automatically without a password. $ adcli preset-computer --domain=domain.example.com host1.example.com host2 Password for Administrator: If the computer names specified contain dots, then they are treated as fully qualified host names, otherwise they are treated as short computer names. The computer accounts must not already exist. In addition to the global options, you can specify the following options to control how this operation is done. -O, --domain-ou=OU=xxx The full distinguished name of the OU in which to create the computer accounts. If not specified then the computer account will be created in a default location. --one-time-password Specify a one time password to use when presetting the computer accounts. If not specified then a default password will be used, which allows for later automatic joins. --os-name=name Set the operating system name on the computer account. The default depends on where adcli was built, but is usually something like 'linux-gnu'. --os-service-pack=pack Set the operating system service pack on the computer account. Not set by default. --os-version=version Set the operating system version on the computer account. Not set by default. --service-name=service Additional service name for a kerberos principal to be created on the computer account. This option may be specified multiple times. --user-principal Set the userPrincipalName field of the computer account to this kerberos principal in the form of host/host.example.com@REALM RESET COMPUTER ACCOUNT
adcli reset-computer resets a computer account in the domain. If a the appropriate machien is currently joined to the domain, then it's membership will be broken. The account must already exist. $ adcli reset-computer --domain=domain.example.com host2 If the computer names specified contain dots, then they are treated as fully qualified host names, otherwise they are treated as short computer names. In addition to the global options, you can specify the following options to control how this operation is done. --login-type={computer|user} Specify the type of authentication that will be performed before creating the machine account in the domain. If set to 'computer' then the computer must already have a preset account in the domain. If not specified and none of the other --login-xxx arguments have been specified, then will try both 'computer' and 'user' authentication. DELETE COMPUTER ACCOUNT
adcli delete-computer deletes a computer account in the domain. The account must already exist. $ adcli delete-computer --domain=domain.example.com host2 Password for Administrator: If the computer name contains a dot, then it is treated as fully qualified host name, otherwise it is treated as short computer name. If no computer name is specified, then the host name of the computer adcli is running on is used, as returned by gethostname(). The various global options can be used. BUGS
Please send bug reports to either the distribution bug tracker or the upstream bug tracker at https://bugs.freedesktop.org/enter_bug.cgi?product=realmd&component=adcli SEE ALSO
realmd(8), net(8), sssd(8) Further details available in the realmd online documentation at http://www.freedesktop.org/software/realmd/ realmd ADCLI(8)
All times are GMT -4. The time now is 03:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy