Sponsored Content
Full Discussion: Rows into columns?
Top Forums Shell Programming and Scripting Rows into columns? Post 302427499 by DeCoTwc on Sunday 6th of June 2010 06:18:25 PM
Old 06-06-2010
Quote:
Originally Posted by bartus11
And on top of that your solution doesn't really give correct results :P At least from the output you are showing here.
Well I'll be a son of a something else...fixed it.

Code:
(01:18:49\[D@DeCoBox15)
[~]$ ./mysolution input > my_results

(01:19:05\[D@DeCoBox15)
[~]$ sdiff expected_results my_results
Joe Smith jsmith 43234 bill1                                    Joe Smith jsmith 43234 bill1
Joe Smith jsmith 43234 bill2                                    Joe Smith jsmith 43234 bill2
Joe Smith jsmith 43234 read                                     Joe Smith jsmith 43234 read
Joe Smith jsmith 43234 read2                                    Joe Smith jsmith 43234 read2
Joe Smith jsmith 43234 schedule                                 Joe Smith jsmith 43234 schedule
Andy Summers asummers 11232 bill1                               Andy Summers asummers 11232 bill1
Andy Summers asummers 11232 read                                Andy Summers asummers 11232 read
Beth McConnel bmconnel 43443 read                               Beth McConnel bmconnel 43443 read
Beth McConnel bmconnel 43443 read2                              Beth McConnel bmconnel 43443 read2
Beth McConnel bmconnel 43443 schedule                           Beth McConnel bmconnel 43443 schedule
Beth McConnel bmconnel 43443 bill                               Beth McConnel bmconnel 43443 bill
Susan Fowler sfowler 09332 bill1                                Susan Fowler sfowler 09332 bill1
Susan Fowler sfowler 09332 read                                 Susan Fowler sfowler 09332 read
Susan Fowler sfowler 09332 schedule                             Susan Fowler sfowler 09332 schedule

(01:19:15\[D@DeCoBox15)
[~]$

This User Gave Thanks to DeCoTwc For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

# of rows and columns

Hi, Does anyone know the command to know the # of rows and columns for a file? thanks (3 Replies)
Discussion started by: kylle345
3 Replies

2. Shell Programming and Scripting

Columns into rows

Hi, Let me know how to achieve the below requirment Input: ======== BEGIN DSSUBRECORD Name "DOC_NO_2" SqlType "-5" Precision "0" Scale "0" Nullable "0" END DSSUBRECORD BEGIN DSSUBRECORD Name "FROM_LOC" ... (1 Reply)
Discussion started by: Ramya_1104
1 Replies

3. Shell Programming and Scripting

rows to columns

Hi Friends, I have a input file as below. how to convert rows to columns? Friday:recharge 3861140 Monday:recharge 4036228 Saturday:recharge 3996376 Sunday:recharge 3777749 Thursday:recharge 3858537 Tuesday:recharge 4047045 Wednesday:recharge 3954798 desinred output Sunday ... (3 Replies)
Discussion started by: suresh3566
3 Replies

4. Shell Programming and Scripting

Rows into Columns

Input File vCenter Servers: 172.28.173.207: vCenter Server connectivity status: Accessible ESX servers: Name: nyp-vhst1001-at.hq.nt.life.com IP address: 10.34.36.11 Virtual machines: Name:nyp-bbmds-at Ip address: 172.28.173.139 ... (1 Reply)
Discussion started by: greycells
1 Replies

5. Shell Programming and Scripting

Rows to Columns

Hi Guru's, I have a requirement where i need to convert rows to column based on a key column. Input: Account_id|Trip_Org|Trip_Dest|City|Hotel_Nm 123|DFW|CHI|Dallas|Hyatt 123|LAS|LPA|Vegas|Hyatt Palace Output:... (6 Replies)
Discussion started by: rakesh5300
6 Replies

6. Shell Programming and Scripting

Deleting all the fields(columns) from a .csv file if all rows in that columns are blanks

Hi Friends, I have come across some files where some of the columns don not have data. Key, Data1,Data2,Data3,Data4,Data5 A,5,6,,10,, A,3,4,,3,, B,1,,4,5,, B,2,,3,4,, If we see the above data on Data5 column do not have any row got filled. So remove only that column(Here Data5) and... (4 Replies)
Discussion started by: ks_reddy
4 Replies

7. Shell Programming and Scripting

Evaluate 2 columns, add sum IF two columns match on two rows

Hi all, I know this sounds suspiciously like a homework course; but, it is not. My goal is to take a file, and match my "ID" column to the "Date" column, if those conditions are true, add the total number of minutes worked and place it in this file, while not printing the original rows that I... (6 Replies)
Discussion started by: mtucker6784
6 Replies

8. Shell Programming and Scripting

Compare 2 csv files by columns, then extract certain columns of matcing rows

Hi all, I'm pretty much a newbie to UNIX. I would appreciate any help with UNIX coding on comparing two large csv files (greater than 10 GB in size), and output a file with matching columns. I want to compare file1 and file2 by 'id' and 'chain' columns, then extract exact matching rows'... (5 Replies)
Discussion started by: bkane3
5 Replies

9. Shell Programming and Scripting

Rows to columns

Hi, I have a text file with records as below Service Contract: Account Type: Client Number: Group Number: Account Currency: I want to print 2nd,3rd and 5th as a separate column, like -> Account Type: ,Client Number: ,Account Currency: How can I do that? (1 Reply)
Discussion started by: dsid
1 Replies

10. UNIX for Beginners Questions & Answers

Columns to rows

HI UNIX Gurus, Not sure if this was already asked and an UNIX Guru has replied but I could not find what i wanted. I have linux environment and need help on this. I have several files like this. a,1 b,1 utc,10/12/2019 local,10/12/2018 name,xxxy deg,feh 10,12 20,8 30,50 32,64 46,65... (5 Replies)
Discussion started by: Roopensingh
5 Replies
aliases(4)							   File Formats 							aliases(4)

NAME
aliases, addresses, forward - addresses and aliases for sendmail SYNOPSIS
/etc/mail/aliases /etc/mail/aliases.db /etc/mail/aliases.dir /etc/mail/aliases.pag ~/.forward DESCRIPTION
These files contain mail addresses or aliases, recognized by sendmail(1M) for the local host: /etc/passwd Mail addresses (usernames) of local users. /etc/mail/aliases Aliases for the local host, in ASCII format. Root can edit this file to add, update, or delete local mail aliases. /etc/mail/aliases.{dir , pag} The aliasing information from /etc/mail/aliases, in binary ndbm(3C) format for use by sendmail(1M). The program newaliases(1M) main- tains these files. /etc/mail/aliases.db The aliasing information from /etc/mail/aliases, in binary, Berkeley DataBase format for use by sendmail(1M). The program maintains these files. Depending on the configuration of the AliasFile option in /etc/mail/sendmail.cf, either the single file aliases.db or the pair of files aliases.{dir, pag} is generated by newaliases(1M). As shipped with Solaris, sendmail(1M) supports both formats. If neither is speci- fied, the Berkeley DataBase format which generates the single .db file is used. ~/.forward Addresses to which a user's mail is forwarded (see Automatic Forwarding). In addition, the NIS name services aliases map mail.aliases, and the NIS+ mail_aliases table, both contain addresses and aliases available for use across the network. Addresses As distributed, sendmail(1M) supports the following types of addresses: Local Usernames username Each local username is listed in the local host's /etc/passwd file. Local Filenames pathname Messages addressed to the absolute pathname of a file are appended to that file. Commands |command If the first character of the address is a vertical bar (|), sendmail(1M) pipes the message to the standard input of the command the bar precedes. Internet-standard Addresses username@domain If domain does not contain any `.' (dots), then it is interpreted as the name of a host in the current domain. Otherwise, the message is passed to a mailhost that determines how to get to the specified domain. Domains are divided into subdomains separated by dots, with the top-level domain on the right. For example, the full address of John Smith could be: js@jsmachine.Podunk-U.EDU if he uses the machine named jsmachine at Podunk University. uucp Addresses ... [host!] host!username These are sometimes mistakenly referred to as ``Usenet'' addresses. uucp(1C) provides links to numerous sites throughout the world for the remote copying of files. Other site-specific forms of addressing can be added by customizing the sendmail.cf configuration file. See sendmail(1M) for details. Stan- dard addresses are recommended. Aliases Local Aliases /etc/mail/aliases is formatted as a series of lines of the form aliasname:address[, address] aliasname is the name of the alias or alias group, and address is the address of a recipient in the group. Aliases can be nested. That is, an address can be the name of another alias group. Because of the way sendmail(1M) performs mapping from upper-case to lower-case, an address that is the name of another alias group must not contain any upper-case letters. Lines beginning with white space are treated as continuation lines for the preceding alias. Lines beginning with # are comments. Special Aliases An alias of the form: owner-aliasname : address sendmail directs error-messages resulting from mail to aliasname to address, instead of back to the person who sent the message. sendmail rewrites the SMTP envelope sender to match this, so owner-aliasname should always point to alias-request, and alias-request should point to the owner's actual address: owner-aliasname: aliasname-request aliasname-request address An alias of the form: aliasname: :include:pathname with colons as shown, adds the recipients listed in the file pathname to the aliasname alias. This allows a private list to be maintained separately from the aliases file. NIS and NIS+ Domain Aliases The aliases file on the master NIS server is used for the mail.aliases NIS map, which can be made available to every NIS client. The mail_aliases table serves the same purpose on a NIS+ server. Thus, the /etc/mail/aliases* files on the various hosts in a network will one day be obsolete. Domain-wide aliases should ultimately be resolved into usernames on specific hosts. For example, if the following were in the domain-wide alias file: jsmith:js@jsmachine then any NIS or NIS+ client could just mail to jsmith and not have to remember the machine and username for John Smith. If a NIS or NIS+ alias does not resolve to an address with a specific host, then the name of the NIS or NIS+ domain is used. There should be an alias of the domain name for a host in this case. For example, the alias: jsmith:root sends mail on a NIS or NIS+ client to root@podunk-u if the name of the NIS or NIS+ domain is podunk-u. Automatic Forwarding When an alias (or address) is resolved to the name of a user on the local host, sendmail(1M) checks for a ~/.forward file, owned by the intended recipient, in that user's home directory, and with universal read access. This file can contain one or more addresses or aliases as described above, each of which is sent a copy of the user's mail. Care must be taken to avoid creating addressing loops in the ~/.forward file. When forwarding mail between machines, be sure that the des- tination machine does not return the mail to the sender through the operation of any NIS aliases. Otherwise, copies of the message may "bounce." Usually, the solution is to change the NIS alias to direct mail to the proper destination. A backslash before a username inhibits further aliasing. For instance, to invoke the vacation program, user js creates a ~/.forward file that contains the line: js, "|/usr/ucb/vacation js" so that one copy of the message is sent to the user, and another is piped into the vacation program. The ~/.forward file can be used to specify special "per user" extensions by creating a .forward+extension file in the home directory. For example, with an address like jsmith+jerry@jsmachine, the sendmail(1M) utility recognizes everything before the "+" as the actual username (jsmith) and everything after it, up to the "@" symbol, as the extension (jerry) which is passed to the mail delivery agent for local use. The default value of the ForwardPath processing option in sendmail(1M) is: O ForwardPath=$z/.forward.$w+$h:$z/.forward+$h:$z/.forward.$w:$z /.forward where $z is the macro for the user's home directory, $w is the macro for the local machine name and $h is the extension. For example, for mail using the address, jsmith+jerry@jsmachine, the sendmail(1M) utility checks each of the four following file names, in the order given, to see if it exists and if it has "safe" permissions, that is, that neither the file nor any of its parent directories are group- or world- writable: ~jsmith/.forward.jsmachine+jerry ~jsmith/.forward+jerry ~jsmith/.forward.jsmachine ~jsmith/.forward The first file that meets the conditions is used to forward the mail, that is, all the entries in that file receive a copy of the mail. The search is then stopped. FILES
/etc/passwd Password file /etc/nsswitch.conf Name service switch configuration file /etc/mail/aliases Mail aliases file (ascii) /etc/mail/aliases.db Database of mail aliases (binary) /etc/mail/aliases.dir Database of mail aliases (binary) /etc/mail/aliases.pag Database of mail aliases (binary) /etc/mail/sendmail.cf sendmail configuration file ~/.forward Forwarding information file ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWsndmr | +-----------------------------+-----------------------------+ SEE ALSO
passwd(1), uucp(1C), vacation(1), newaliases(1M), sendmail(1M), ndbm(3C), getusershell(3C), passwd(4), shells(4), attributes(5) NOTES
Because of restrictions in ndbm(3C), a single alias cannot contain more than about 1000 characters (if this format is used). The Berkeley DataBase format does not have any such restriction. Nested aliases can be used to circumvent this limit. For aliases which result in piping to a program or concatenating a file, the shell of the controlling user must be allowed. Which shells are and are not allowed are determined by getusershell(3C). SunOS 5.11 8 May 2006 aliases(4)
All times are GMT -4. The time now is 03:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy