Sponsored Content
Top Forums Shell Programming and Scripting Help with ... Formating the file using awk Post 303018074 by RudiC on Monday 28th of May 2018 12:06:55 PM
Old 05-28-2018
It REALLY were helpful IF you could verbally, carefully, detailedly describe your request and not leave it to the people in here to guess what you want from inconsistent samples! There's no position2 with a "-" in field 6, and it's nowhere told that "-" in $6 must not count like "client5" does. And, with the NR > 2 applied to your sample, the "position1" count is one to low.


Try these essays, all based on and adapted from your attempt above, on your problems and report back:
Code:
awk -F"[ :\t]+" 'NF {A[$1]++}END{for(i in A)print i,A[i]}' OFS=, file4
position1,4
position2,3
position3,3
awk -F"[ :\t]+" 'NF && $6 != "-" {A[$1]++}END{for(i in A)print i,A[i]}' OFS=, file4
position1,4
position2,3
position3,2
awk -F"[ :\t]+" 'NF {A[$1,$6]++}END{for(i in A)print i,A[i]}' OFS=, SUBSEP=, file4
position3,-,1
position3,client5,2
position2,client4,2
position2,client3,1
position1,client2,1
position1,client1,3

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help required on file formating

I have two files file1 and file2 as shown below: file1: name nameabc bcd nameabcdefg file2: age age1111 age2345 age6743 I have pasted one file on the other with the delimiter "|" and the resulttant file is: name|age nameabc|age1111 bcd|age2345 nameabcdefg|age6743 (1 Reply)
Discussion started by: udiptya
1 Replies

2. Shell Programming and Scripting

AWK: formating number without printf

Hello, I wrote a script that does lot of things, and I would like to change the format of a number but without printing it now (so I don't want to use printf as it will print the value immediately). Schematically here is what I have: awk 'BEGIN{number=0.01234567} $1==$2{$3=number}... (5 Replies)
Discussion started by: jolecanard
5 Replies

3. Shell Programming and Scripting

file formating in Perl

Hi, I am new to unix , I have a requirement for formating the input file and generate the output file as per the downstream requirement .. My application receiving a text input file having 4 field and my application need to check each field and if some value of a field is blank ..then it need... (1 Reply)
Discussion started by: julirani
1 Replies

4. UNIX for Dummies Questions & Answers

File formating help needed.

I have a file called vm.cfg . content of file. acpi = 1 apic = 1 builder = 'hvm' How would i write a script which will add boot = 'd' at 3rd line. For example. after running the script the file should be like below. acpi = 1 apic = 1 boot = 'd' builder = 'hvm' I dont want to... (3 Replies)
Discussion started by: pinga123
3 Replies

5. Shell Programming and Scripting

Help in formating a txt file

Pls help in formatting a txt file using shell scripting Input file format: Name priya 2010-09-21 10:43:49 TEXT ID 1 hi TEXT ID 2 how TEXT ID 3 r TEXT ID 4 u Output required: name priya hi how r u (4 Replies)
Discussion started by: bha148
4 Replies

6. Shell Programming and Scripting

formating sql file using awk or sed

Hi, I have a file where I would like to add a prompt type object_name statement before every create commnad create or replace force view test_view_01 ( col1 col2 col3 ) as (select a,b,c from sometable ); create or replace view test_view_02 ( col4 col5 col6 ) as (5 Replies)
Discussion started by: jville
5 Replies

7. UNIX for Beginners Questions & Answers

File formating with lines

Hi All, Need to modify a file basically join the extra line to one I am having a file like below And would like to make it as below . (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

8. UNIX for Beginners Questions & Answers

File formating help

Hi all, I am having the file below I need that as below Thanks, Arun (12 Replies)
Discussion started by: arunkumar_mca
12 Replies

9. Shell Programming and Scripting

File formating

I need to create a fixed width file based on the column lengths. lets assume I have six(this may be dynamic) fields each are of different length column1=6 #size of the column column2=3 column3=2 column4=3 column5=4 column6=5 I tried below code snippet but it is not working echo... (4 Replies)
Discussion started by: gvkumar25
4 Replies

10. UNIX for Beginners Questions & Answers

awk HTML Conditional Formating

I am receiving the below output in text format. The output is converted to HTML table using the code mentioned below output in text LogDate DayOfWeek/Hours _0_ _1_ _2_ _3_ _4_ _5_ _6_ _7_ _8_ _9_ _10_ _11_ _12_ _13_ _14_ _15_ _16_ ... (3 Replies)
Discussion started by: Dumpi16
3 Replies
bootparams(4)							   File Formats 						     bootparams(4)

NAME
bootparams - boot parameter data base SYNOPSIS
/etc/bootparams DESCRIPTION
The bootparams file contains a list of client entries that diskless clients use for booting. Diskless booting clients retrieve this infor- mation by issuing requests to a server running the rpc.bootparamd(1M) program. The bootparams file may be used in conjunction with or in place of other sources for the bootparams information. See nsswitch.conf(4). For each client the file contains an entry with the client's name and a list of boot parameter values for that client. Each entry has the form: clientname keyword=value... The first item of each entry is the host name of the diskless client. You can use the asterisk ('*') character as a "wildcard" in place of the client name in a single entry. A wildcard entry applies to all clients for which there is not an entry that specifically names them. In a given entry, the host name or asterisk is followed by one or more whitespace characters and a series of keyword--value pairs separated by whitespace characters. There must not be any whitespace within a keyword--value pair. Each keyword--value pair has the syntax: keyword=value The preceding form breaks out further as: keyword=server:value Where server can be null and value can be a pathname. An example that includes a server is: client1 root=server1:/export/client1/root An example where server is null is: client1 rootopts=:vers2 A minor variation of the keyword=value syntax is used for the domain keyword. Unlike the forms shown above, this syntax does not use a colon. For example: client1 domain=bldg1.workco.com Entries can span multiple lines. Use the backslash ('') character as the last character of a line to continue the entry to the following line. For multiple-line entries, you can split a line only in places where whitespace is allowed. For example, you can use a backslash to split the following entry between the end of the path (root) and the keyword domain: client1 root=server1:/export/client1/root domain=bldg1.workco.com In entries that specify a server, server is the name of the server that will provide the file or filesystem to the diskless client and value is the pathname of the exported file or filesystem on that server. In entries that use the domain keyword, the domain name specified must be the client's domain name. The algorithm for determining a client's domain name is to first check for a domain keyword in the client-specific entry and then in "wildcard" entry. If none is found, the server's domain name is used. For the JumpStart installation of machines that do not have video displays, use the term keyword to identify the terminal type of the boot server. Terminal types are listed in /usr/share/lib/terminfo (see terminfo(4)). An entry with the ns keyword associates a server (a name server) with, instead of a pathname, a specific name service (NIS+, NIS, LDAP, or none) and, if that server is not on a local subnet, the netmask needed to reach it. For example: ns=hoot:nisplus(255.255.255.0) An ns entry forces sysidtool(1M) to use the specified name service. By default, sysidtool uses NIS+ in preference to NIS or LDAP if it can find an NIS+ server for the system's domain on the subnet. An ns entry might be necessary if you are trying to set up a hands-off installa- tion, or if the name server is on a different subnet, which is common with NIS+. If an ns keyword is not used, sysidtool uses broadcast to attempt to bind to either a NIS+, NIS, or LDAP server. If a name server is not on the local subnet, which is possible for NIS+ or LDAP, the bind will fail, automatic configuration of the name service will fail, and an interactive screen is displayed, prompting the user to specify the name service. The ns keyword can be set in add_install_client or by Host Manager. EXAMPLES
Example 1: Sample bootparams Entry Here is an example of an entry in the bootparams file: client1 root=server1:/export/client1/root rootopts=:vers=2 domain=bldg1.workco.com client2 root=server2:/export/client2/root ns=:nis client3 root=server2:/export/client3/root ns=watson: client4 root=server2:/export/client4/root ns=mach:nisplus(255.255.255.0) Example 2: Sample Entry for JumpStart The following is an example of an entry that might be used for the JumpStart installation of diskless clients that do not have displays. mozart root=haydn:/export/install/sparc/os/latest/Solaris_9/boot install=haydn:/export/install/sparc/os/8.1/latest boottype=:in install_config=haydn:/usr/local/share/lib/jump-net ns=otis:nisplus(255.255.255.0) term=:xterms domain=eu.cte.work.com FILES
/etc/bootparams SEE ALSO
rpc.bootparamd(1M), sysidtool(1M), nsswitch.conf(4) NOTES
Solaris diskless clients use the keywords root and rootopts to look up the pathname for the root filesystem and the mount options for the root filesystem, respectively. These are the only keywords meaningful for diskless booting clients. See mount_ufs(1M). SunOS 5.10 22 Jul 2004 bootparams(4)
All times are GMT -4. The time now is 04:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy