Sponsored Content
Full Discussion: Pivot file using shellscript
Top Forums Shell Programming and Scripting Pivot file using shellscript Post 302995891 by shanlinux on Friday 14th of April 2017 08:36:46 AM
Old 04-14-2017
Pivot file using shellscript

Hi, I am new at using shell scripting. So I have a question for the more experienced Linux users. I would like to perform some kind of pivot on a file.

Example Input file
Code:
COL1,"2001-01-01","2001-03-01","2001-03-24"
A1,22,,44
B1,56,78,12
C2,5,,

I would like to have to following output
Code:
A1,"2001-01-01",22
A1,"2001-03-24",44
B1,"2001-01-01",56
B1,"2001-03-01",78
B1,"2001-03-24",12
C2,"2001-01-01",5

Any help is appreciated.

Last edited by vgersh99; 04-14-2017 at 09:56 AM.. Reason: code tags, please!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting Pivot file to flat file

I have a file in this format. P1 P2 P3......................... A001 v11 v21 v31...................... A002 v12 v22 v32............................ A003 v13 v23 v33.......................... A004 v14 v24 v34.............................. . . . A00n... (2 Replies)
Discussion started by: vskr72
2 Replies

2. Shell Programming and Scripting

Pivot variable record length file and change delimiter

Hi experts. I got a file (500mb max) and need to pivot it (loading into ORCL) and change BLANK delimiter to PIPE |. Sometimes there are multipel BLANKS (as a particular value may be BLANK, or simply two BLANKS instead of one BLANK). thanks for your input! Cheers, Layout... (3 Replies)
Discussion started by: thomasr
3 Replies

3. Shell Programming and Scripting

Check file exists from a shellscript

Hi, I have a list of files that I want to check to see if they exist and then count how many of these files exist, I also want to do the same for the files that arent found. I have done this by creating temp files see below but want ot do this using variables instead: for FILE in... (7 Replies)
Discussion started by: tonydsam
7 Replies

4. Shell Programming and Scripting

Pivot file contents

Hi All, I am trying to pivot the contents in a file. Ex: I have a file sample.txt with data "A B C D", i need the contents to pivot & resulting file should look like "A B C ... (3 Replies)
Discussion started by: new_ds_man
3 Replies

5. Shell Programming and Scripting

How to rename file-using shellscript?

Hi All, need your help in renaming the file ? Please read the below data carefully. Its may b simple for you :-) just information is too long Eg-home/user01/exercise contains abc.log, ppp.log ,shd.log want to rename this file with timestamp using shellscript for this i... (8 Replies)
Discussion started by: aish11
8 Replies

6. Shell Programming and Scripting

Please help me to print particular line in the file using shellscript

Plese help me on this below I have to do below 2 things in a single shell script 1) I have to search one word(eg : red) from the below sample file. 2) Then if I am getting word in the 3rd line (red) then I need to print the above 2 lines and below 2 lines from thekeyword For Example:... (5 Replies)
Discussion started by: Maanjesh
5 Replies

7. UNIX for Dummies Questions & Answers

Script to pivot flat file

Hi to all, I have a file with a list of values: v1,v2,v3....,v9 need file in this format: Name1: v1 Name2: v2 Name3: v3 ... Name9: v9 Please help me out. (2 Replies)
Discussion started by: mozi
2 Replies

8. Shell Programming and Scripting

Pivot file content

Hi All , I have a file as below . A "1" B "2" C "3" D "4" E "5" F "6" A "11" B "21" C "31" D "41" E "51" F "61" And the output should be like A B C D E F 1 2 3 4 5 6 11 21 31 41 51 (8 Replies)
Discussion started by: saj
8 Replies

9. Shell Programming and Scripting

How to pass a shellscript variable to a sql file?

Hi, i wan't to pass a shellscript variable to a sql file. a.sql select $field from dual; the way i am calling this is through sqlplus field_name="sysdate" sqlplus -s username/password@hostname:port/servicename <<EOF @a.sql $field_name EOF (4 Replies)
Discussion started by: reignangel2003
4 Replies

10. Shell Programming and Scripting

Create a pivot table from CSV file

Gents, Can you please help me to create a pivot table from a csv file. ( I have zip the csv file) Using the file attached, columns 1,28 and 21 i would like to get something like this output JD Val 1 2 3 4 5 6 7 8 9 10 11 12 Total... (4 Replies)
Discussion started by: jiam912
4 Replies
platform::shell(n)					       Tcl Bundled Packages						platform::shell(n)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(n)
All times are GMT -4. The time now is 08:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy