Sponsored Content
Top Forums Shell Programming and Scripting Put repeated values into a table Post 302876596 by Akshay Hegde on Monday 25th of November 2013 01:47:04 PM
Old 11-25-2013
Quote:
Originally Posted by RavinderSingh13
Hello Akshay,

Thanks for great code could you please explain the same.


Thanks,
R. Singh
awk '!A[$1]++{s = s ? s OFS $1 : $1}.... --> Here unique records from column 1 are stored in variable s

{B[++i]=$2} --> Array B holds column2 records

and finally in END block

END{print s;.. --> Prints unique records in variable s

for(j=1;j<=i;j++) --> Looping for 1 to i

B[j] !~ /[[:alnum:]]/ || j == i ? RS : OFS --> if B[j] is not alphanumeric or j equal to i thats end of loop print B[j] and Row separator ("\n") else print B[j] and output field separator (OFS)
This User Gave Thanks to Akshay Hegde For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

Can I put my own tags in a partition table

I have X4500 running Solaris 10. I have formatted a disk and created partition table as given below. Specify disk (enter its number): 0 selecting c0t0d0 /dev/dsk/c0t0d0s0 is part of active ZFS pool zpool1. Please see zpool(1M). FORMAT MENU: disk - select a disk ... (3 Replies)
Discussion started by: bharu_sri
3 Replies

2. Shell Programming and Scripting

To Delete the repeated occurances and print in same line by appending values

Hi All, I am trying to work on below text a b c 1 a b c 2 a b c 3 x y z 6 x y z 44 a b c 89 Need to delete the occurances and get in single line like below: a b c 1 2 3 89 x y z 6 44 89 Please help me i am new into unix scripting ..... ---------- Post updated at 03:00... (8 Replies)
Discussion started by: shaliniyadav
8 Replies

3. Shell Programming and Scripting

comparing the values of repeated keys in multiple columns

Hi Guyz The 1st column of the input file has repeated keys like x,y and z. The ist task is if the 1st column has unique key (say x) and then need to consider 4th column, if it is + symbol then subtract 2nd column value with 3rd column value (we will get 2(10-8)) or if it is - symbol subtract 3rd... (3 Replies)
Discussion started by: repinementer
3 Replies

4. Shell Programming and Scripting

select values from db1 table and insert into table of DB2

Hi I am having three oracle databases running in three different machine. their ip address is different. from one of the DB am able to access both the databases.(means am able to select values and insert values in to tables individually.) I need to fetch some data from DB1 table(say DB1 ip is... (2 Replies)
Discussion started by: aemunathan
2 Replies

5. Shell Programming and Scripting

remove brackets and put it in a column and remove repeated entry

Hi all, I want to remove the remove bracket sign ( ) and put in the separate column I also want to remove the repeated entry like in first row in below input (PA156) is repeated ESR1 (PA156) leflunomide (PA450192) (PA156) leflunomide (PA450192) CHST3 (PA26503) docetaxel... (2 Replies)
Discussion started by: manigrover
2 Replies

6. Shell Programming and Scripting

How do I put data piped to my script into an array for repeated processing

Hi folks, Sorry for something I'm sure was answered already, I just could not find it in a search of the forums. I am trying to build a script that eats a config file as: cat file.cnf | ConProcess.shWhat I want to do inside the script is: !#/usr/bin/bash # captured piped cat into an... (6 Replies)
Discussion started by: Marc G
6 Replies

7. Shell Programming and Scripting

Resume and count repeated values

Gents, Please can you help me. Input file 1050 , 9 ,9888 1050 ,10 ,9888 1050 ,11 ,9888 1050 ,13 ,9888 1050 ,15 ,9888 1051 , 9 ,9889 1051 ,12 ,9889 1051 ,15 ,9889 1051 ,18 ,9889 1052 , 9 ... (7 Replies)
Discussion started by: jiam912
7 Replies

8. Shell Programming and Scripting

Query the table and return values to shell script and search result values from another files.

Hi, I need a shell script, which would search the result values from another files. 1)execute " select column1 from table_name" query on the table. 2)Based on the result, need to be grep from .wft files. could please explain about this.Below is the way i am using. #!/bin/sh... (4 Replies)
Discussion started by: Rami Reddy
4 Replies

9. Shell Programming and Scripting

awk file to read values from Db2 table replacing hard coded values

Hi, I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below... if (start_new_rec=="true"){ exclude_user="false"; user=toupper($6); match(user, "XXXXX."); if (RSTART ==2 ) { ... (9 Replies)
Discussion started by: asandy1234
9 Replies

10. Shell Programming and Scripting

Adding the values of repeated ids

File1 consist two columns, first some weired ids and second the numbers t|v203.1@t|k88711.1 0.1 t|v190.1@t|k90369.1 0.01 t|v203.1@t|k88711.1 0.5 t|v322.1@t|k88711.1 0.2 t|v207.1@t|k90369.1 0.11 t|v326.1@t|k85939.1 0.5 t|v207.1@t|k90369.1 0.7 t|v207.1@t|k90369.1 0.3 t|v326.1@t|k89421.1 0.33... (3 Replies)
Discussion started by: ashmit99
3 Replies
DUMP(5) 							File Formats Manual							   DUMP(5)

NAME
dump, ddate - incremental dump format SYNOPSIS
#include <sys/types.h> #include <sys/ino.h> # include <dumprestor.h> DESCRIPTION
Tapes used by dump and restor(1) contain: a header record two groups of bit map records a group of records describing directories a group of records describing files The format of the header record and of the first record of each description as given in the include file <dumprestor.h> is: NTREC is the number of 512 byte records in a physical tape block. MLEN is the number of bits in a bit map word. MSIZ is the number of bit map words. The TS_ entries are used in the c_type field to indicate what sort of header this is. The types and their meanings are as follows: TS_TAPE Tape volume label TS_INODE A file or directory follows. The c_dinode field is a copy of the disk inode and contains bits telling what sort of file this is. TS_BITS A bit map follows. This bit map has a one bit for each inode that was dumped. TS_ADDR A subrecord of a file description. See c_addr below. TS_END End of tape record. TS_CLRI A bit map follows. This bit map contains a zero bit for all inodes that were empty on the file system when dumped. MAGIC All header records have this number in c_magic. CHECKSUM Header records checksum to this value. The fields of the header structure are as follows: c_type The type of the header. c_date The date the dump was taken. c_ddate The date the file system was dumped from. c_volume The current volume number of the dump. c_tapea The current number of this (512-byte) record. c_inumber The number of the inode being dumped if this is of type TS_INODE. c_magic This contains the value MAGIC above, truncated as needed. c_checksum This contains whatever value is needed to make the record sum to CHECKSUM. c_dinode This is a copy of the inode as it appears on the file system; see filsys(5). c_count The count of characters in c_addr. c_addr An array of characters describing the blocks of the dumped file. A character is zero if the block associated with that character was not present on the file system, otherwise the character is non-zero. If the block was not present on the file system, no block was dumped; the block will be restored as a hole in the file. If there is not sufficient space in this record to describe all of the blocks in a file, TS_ADDR records will be scattered through the file, each one picking up where the last left off. Each volume except the last ends with a tapemark (read as an end of file). The last volume ends with a TS_END record and then the tape- mark. The structure idates describes an entry of the file /etc/ddate where dump history is kept. The fields of the structure are: id_name The dumped filesystem is `/dev/id_nam'. id_incno The level number of the dump tape; see dump(1). id_ddate The date of the incremental dump in system format see types(5). FILES
/etc/ddate SEE ALSO
dump(1), dumpdir(1), restor(1), filsys(5), types(5) DUMP(5)
All times are GMT -4. The time now is 08:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy