Sponsored Content
Top Forums Shell Programming and Scripting Cut determinate values amb subst for ; Post 302709325 by capilla on Wednesday 3rd of October 2012 05:49:43 AM
Old 10-03-2012
Hello Thanks for your reply. I try with the metodes and doesn't work :-(. The result is:
Code:
cut -d' ' -f2- file|paste -sd';\n' extractcritiques.txt
 host_name       cedf-ddt              ;       address         10.14.138.3
        host_name       dfb-crft             ;       address         10.14.184.2
        host_name       cesdneb-cerferu             ;       address         10.14.184.3
        host_name       cenfeeb-derfx;     address         10.14.139.10

Code:
awk 'FNR%2 {print name, $2;next}{name=$2}' OFS=';' extractcritiques.txt | more

;cdceb-adn
10.14.176.6;ceneb-fg
10.14.176.7;ceneb-arerfg
10.14.200.4;ceneb-arrefer
10.14.200.5;ceneb-brfer
10.14.244.96;ceneb-sacrf
10.14.244.97;ceneb-cacrf

I think the problem is the space in to the origen file:
Code:
    host_name       cendfseb-ardfdf
        address         10.14.176.6
        host_name       cesdfb-arsdf
        address         10.14.176.7
        host_name       csgb-atg
        address         10.14.200.4
        host_name       certhrteb-artg

Sorry in my first message don't appear the spaces (or tabulations) because I put in (Wrap quote). awk is very interesting. I'm read the documentation in this moment.

Last edited by Scrutinizer; 10-03-2012 at 07:01 AM.. Reason: code tags instead of quote tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command param subst to reg expression

I want to find out Row which starts with, the user specified details to a script. In general I know what command to be given. awk '$0~/^Vi/' BReject But I need to pass on $1 param of command line at the place of 'Vi'. I tried with -v subst=$1 awk -v subst=$1 '$0~/^subst/' BReject But it... (5 Replies)
Discussion started by: videsh77
5 Replies

2. UNIX for Dummies Questions & Answers

to assign cut values to an array

i need to seperate values seperated by delimiters and assign it to an array.. can u plz help me on that. Variables = "asd,rgbh,(,rty,got,),sroe,9034," i need to assign the variables into arrays.. like.. var=asd var=rgbh.. and so on how do i do this. i need to reuse the values stored in... (6 Replies)
Discussion started by: Syms
6 Replies

3. Shell Programming and Scripting

Iterative statement to cut values from a line

Hi I am new to shell scripting and trying to get values from a text file, I have a text file with values seperated with "|". like aga|120220090525|120220090525|120220090525|120220090530 bab|120220090530|120220090530|120220090535|120220090535|120220090535... (4 Replies)
Discussion started by: mannepalli
4 Replies

4. UNIX for Dummies Questions & Answers

Parse or cut concat variables to individual values

Hello I need to pass some environment parameters to a datastage job and am getting an error when trying to send the complete concatinated variable. I have decided to parse out just the values and send as parameters but am struggling to find the best way to do this (actually I am not very... (3 Replies)
Discussion started by: LynnC
3 Replies

5. Shell Programming and Scripting

Delete character in determinate position with sed/awk

Hello. I'm trying to delete one character in determinate position. Example: qwEtsdf123Ecv34 <delete character in positión 3> Result: qwtsdf123Ecv34 Plase, help me. Thanks (4 Replies)
Discussion started by: maria_florencia
4 Replies

6. Shell Programming and Scripting

CSV with commas in field values, remove duplicates, cut columns

Hi Description of input file I have: ------------------------- 1) CSV with double quotes for string fields. 2) Some string fields have Comma as part of field value. 3) Have Duplicate lines 4) Have 200 columns/fields 5) File size is more than 10GB Description of output file I need:... (4 Replies)
Discussion started by: krishnix
4 Replies

7. UNIX for Dummies Questions & Answers

Cut from tables based on column values

Hello, I have a tab-delimited table that may contain 11,12 or 13 columns. Depending on the number of columns, I want to cut and get a sub table as shown below. However, the awk commands in the code seem to be an issue. What should I be doing differently? #cut columns 1-2,4-5,11 when 12 &... (3 Replies)
Discussion started by: Gussifinknottle
3 Replies

8. Shell Programming and Scripting

A simple variable subst is not working

Hi what i want: listing files in a special range ls -lrt 20120601{05..06}* ... -rw-rw-r-- 1 imp imp 279 1. Jun 07:51 201206010550 -rw-rw-r-- 1 imp imp 279 1. Jun 07:01 201206010600 -rw-rw-r-- 1 imp imp 279 1. Jun 07:11 201206010610 -rw-rw-r-- 1 imp imp 279 1. Jun 07:21... (1 Reply)
Discussion started by: IMPe
1 Replies

9. Shell Programming and Scripting

Using make subst

I have a string of source files ENBL_PX11_LIBSRC = pltsub.f xpltlib.f xbuplot.cI want to replace .f and .c with .o to get ENBL_PX11_LIBOBJ = pltsub.o xpltlib.o xbuplot.o However I am having trouble doing this with subst. (5 Replies)
Discussion started by: kristinu
5 Replies

10. Shell Programming and Scripting

Cut command with dynamic passing of delimiter and position values

Hi All, We have a requirement of picking nth position value by using cut command. value would be delimited by any symbols. We have to pass delimited value and postition to get the value in a string. ex. echo "A,B,C,D,E" |cut -d "," -f3 echo "A|B|C|D|E"|cut -d "|" -f2 Kindly frame the... (5 Replies)
Discussion started by: KK230689
5 Replies
smtnrhdb(1M)						  System Administration Commands					      smtnrhdb(1M)

NAME
smtnrhdb - manage entries in the tnrhdb database SYNOPSIS
/usr/sadm/bin/smtnrhdb subcommand [auth_args] -- subcommand_args] DESCRIPTION
The smtnrhdb command adds, modifies, deletes, and lists entries in the tnrhdb database. The tnrhdb database specifies which remote-host template to use for each host, including the local host, in the distributed system. If a host's IP address cannot be matched to some entry in the tnrhdb database, communication with the host is not permitted. The smtnrhdb command requires the Solaris Management Console to be initialized for the command to succeed (see smc(1M)). After rebooting the Solaris Management Console server, the first smc connection can time out, so you might need to retry the command. Valid Host Addresses and Wildcards The trusted network software uses a network "longest prefix of matching bits" mechanism when looking for a host. The software looks first for the IP address of the host. If the software does not find this address, then the software falls back to searching for an IP address with the longest prefix of a matching bit pattern, and so on. Note - The actual numeric value of the subnet address or other subnetting information on the system (for example, from the netmasks(4) file) are not considered by this mechanism. Using the "longest prefix of matching bits" mechanism, an IPv4 address of 0.0.0.0 is a wildcard address with a prefix length of 0 and hence matches any IPv4 address. For more information about prefi x lengths in IPv4 and IPv6 addresses, see System Administration Guide: IP Ser- vices. The smtnrhdb command accepts a hostname, IP address, and wildcard address with as optional prefix as valid addresses. See subcommand_args, below, for the format of valid addresses. SUB-COMMANDS smtnrhdb subcommands are: add Adds a new entry to the tnrhdb database. To add an entry, the administrator must have the solaris.network.host.write and solaris.net- work.security.write authorizations. delete Deletes an entry from the tnrhdb database. To delete an entry, the administrator must have the solaris.network.host.write and solaris.network.security.write authorizations. list Lists all entries in the tnrhdb database. To list an entry, the administrator must have the solaris.network.host.read and solaris.net- work.security.read authorizations. modify Modifies an entry in the tnrhdb database. To modify an entry, the administrator must have the solaris.network.host.write and solaris.network.security.write authorizations. OPTIONS
The smtnrhdb authentication arguments, auth_args, are derived from the smc arg set. These arguments are the same regardless of which sub- command you use. The subcommand-specific options, subcommand_args, must be preceded by the -- option. auth_args The valid auth_args are -D, -H, -l, -p, -r, and -u; they are all optional. If no auth_args are specified, certain defaults will be assumed and the user might be prompted for additional information, such as a password for authentication purposes. These letter options can also be specified by their equivalent option words preceded by a double dash. For example, you can use either -D or --domain. -D | --domain domain Specifies the default domain that you want to manage. The syntax of domain=type:/host_name/domain_name, where type is dns, ldap, or file; host_name is the name of the server; and domain_name is the name of the domain you want to manage. If you do not specify this option, the Solaris Management Console assumes the file default domain on whatever server you choose to man- age, meaning that changes are local to the server. Toolboxes can change the domain on a tool-by-tool basis; this option specifies the domain for all other tools. -H | --hostname host_name:port Specifies the host_name and port to which you want to connect. If you do not specify a port, the system connects to the default port, 898. If you do not specify host_name:port, the Solaris Management Console connects to the local host on port 898. -l | --rolepassword role_password Specifies the password for the role_name. If you specify a role_name but do not specify a role_password, the system prompts you to sup- ply a role_password. Passwords specified on the command line can be seen by any user on the system, hence this option is considered insecure. -p | --password password Specifies the password for the user_name. If you do not specify a password, the system prompts you for one. Passwords specified on the command line can be seen by any user on the system, hence this option is considered insecure. -r | --rolename role_name Specifies a role name for authentication. If you do not specify this option, no role is assumed. -u | --username user_name Specifies the user name for authentication. If you do not specify this option, the user identity running the console process is assumed. -- This option is required and must always follow the preceding options. If you do not enter the preceding options, you must still enter the -- option. subcommand_args Note: Descriptions and other arg options that contain white spaces must be enclosed in double quotes. -h Displays the command's usage statement. -H hostname Specifies the name of the host. For the list subcommand, the hostname argument is not specified. This is not required if the ipaddress subcommand argument is specified. -i ipaddress Specifies the IP address of the host. This is not required if the hostname subcommand argument is specified. This option is not valid with the -w option. -n templatename Specifies the name of an existing template. -p prefixlen Specifies the prefix length (in bits) of a wildcard representation of the IP address. The prefix is the left-most portion of the IP address. This option is valid only with the -w option. For example, when the value of -w ipaddress-wildcard is 192.168.0.0, a prefixlen value of 24 indicates that the wildcard matches all addresses on the 192.168.0 network. With a prefixlen of 32, the wildcard 192.168.0.0 matches all addresses on the 192.168.0.0 network. -w ipaddress-wildcard Specifies the IP address of the subnet using a wildcard. o One of the following sets of arguments must be specified for subcommand add: -H hostname -n templatename | -i ipaddress -n templatename | -w ipaddress-wildcard -n templatename [ -p prefixlen ] | -h o One of the following sets of arguments must be specified for subcommand modify: -H hostname -n templatename | -i ipaddress -n templatename | -w ipaddress-wildcard -n templatename [ -p prefixlen ] | -h o One of the following sets of arguments must be specified for subcommand delete: -H hostname | -i ipaddress | -w ipaddress-wildcard [ -p prefixlen ] | -h o The subcommand list takes the following argument: -h EXAMPLES
Example 1 Specifying the Template Name for a Wildcard IP Address The admin role specifies the template name, cipso_lan, for a series of hosts that use the IP address wildcard 192.168.113.0 on the local file system. Since no authorization arguments were specified, the administrator connects to port 898 of the local host on the local server with the file domain type, which are the defaults. The administrator is prompted for the admin password. $ usr/sadm/bin/smtnrhdb add -- -w 192.168.113.0 -n cipso_lan Example 2 Deleting an Entry in the tnrhdb Database The admin role connects to port 898 (which happens to be the default) of the LDAP server and deletes a host entry from the database by specifying its IP address, 192.168.113.8. Since the domain was not specified, the file domain type and local server are used by default. The administrator is prompted for the admin password. # /usr/sadm/bin/smtnrhdb delete -D ldap:/example.domain -i 192.168.113.8 Example 3 Adding a Subnet to the tnrhdb Database The following command adds all the addresses on the 192.168.55.0 subnet, from 192.168.55.1 to 192.168.55.255, to the tnrhdb database: # /usr/sadm/bin/smtnrhdb add -D file:/machine1.ExampleCo.COM/machine1.ExampleCo.COM -- -w 192.168.55.0 -n cipso Authenticating as user: root Type /? for help, pressing <enter> accepts the default denoted by [ ] Please enter a string value for: password :: Loading Tool: com.exampleco.admin.hostmgr.cli.smtnrhdb.HostMgrTnrhdbCli from machine1.ExampleCo.COM Login to machine1.ExampleCo.COM as user root was successful. Download of com.exampleco.admin.hostmgr.cli.smtnrhdb.HostMgrTnrhdbCli from machine1.ExampleCo.COM was successful. Example 4 Adding Subnet 192.168.0 to the tnrhdb Database The following command adds all the addresses on the 192.168.0 subnet, from 192.168.0.1 to 192.168.0.255 to the tnrhdb database. The prefix, 24, indicates that the first 24 bits (192.168.0) are fixed. Only the final zero is a wildcard. # /usr/sadm/bin/smtnrhdb add -D file:/machine1.ExampleCo.COM/machine1.ExampleCo.COM -- -w 192.168.0.0 -p 24 -n cipso Login to machine1.ExampleCo.COM as user root was successful. Download of com.exampleco.admin.hostmgr.cli.smtnrhdb.HostMgrTnrhdbCli from machine1.ExampleCo.COM was successful. EXIT STATUS
The following exit values are returned: 0 Successful completion. 1 Invalid command syntax. A usage message displays. 2 An error occurred while executing the command. An error message displays. FILES
The following files are used by the smtnrhdb command: /etc/security/tsol/tnrhdb Trusted network remote-host database. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWmgts | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ SEE ALSO
smc(1M), netmasks(4), attributes(5) System Administration Guide: Security Services NOTES
The functionality described on this manual page is available only if the system is configured with Trusted Extensions. SunOS 5.11 19 Dec 2008 smtnrhdb(1M)
All times are GMT -4. The time now is 11:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy