Sponsored Content
Top Forums Shell Programming and Scripting Add column header and row header Post 302774289 by jacobs.smith on Friday 1st of March 2013 02:10:50 PM
Old 03-01-2013
Add column header and row header

Hi,

I have an input like this

Code:
1 2 3 4
2 3 4 5
4 5 6 7

I would like to count the no. of columns and print a header with a prefix "Col".

I would also like to count the no. of rows and print as first column with each line number with a prefix "Row"

So, my output would be

Code:
        Col1 Col2 Col3 Col4
Row1     1     2     3     4
Row2     2     3     4     5
Row3     4     5     6     7

 

10 More Discussions You Might Find Interesting

1. Linux

Reading the header of a tar file(posix header)

say i have these many file in a directory named exam. 1)/exam/newfolder/link.txt. 2)/exam/newfolder1/ and i create a tar say exam.tar well the problem is, when i read the tar file i dont find any metadata about the directories,as you cannot create a tar containig empty directories. on the... (2 Replies)
Discussion started by: Tanvirk
2 Replies

2. UNIX for Dummies Questions & Answers

split header row into one column

So, I have a massive file with thousands of columns I want a list of the headers in one column in another file. So I need to strip off the top line (can use head-1) But how can I convert from this format: A B C D E F G to A B C D E F G (6 Replies)
Discussion started by: polly_falconer
6 Replies

3. Shell Programming and Scripting

Rename a header column by adding another column entry to the header column name URGENT!!

Hi All, I have a file example.csv which looks like this GrpID,TargetID,Signal,Avg_Num CSCH74_1_1,2007,61,256 CSCH74_1_1,212007,647,679 CSCH74_1_1,12007,3,32 CSCH74_1_1,207,299,777 I want the output as GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num CSCH74_1_1,2007,61,256... (4 Replies)
Discussion started by: Vavad
4 Replies

4. UNIX for Dummies Questions & Answers

Rename a header column by adding another column entry to the header column name

Hi All, I have a file example.csv which looks like this GrpID,TargetID,Signal,Avg_Num CSCH74_1_1,2007,61,256 CSCH74_1_1,212007,647,679 CSCH74_1_1,12007,3,32 CSCH74_1_1,207,299,777 I want the output as GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num CSCH74_1_1,2007,61,256... (1 Reply)
Discussion started by: Vavad
1 Replies

5. UNIX for Dummies Questions & Answers

Merge all csv files in one folder considering only 1 header row and ignoring header of all others

Friends, I need help with the following in UNIX. Merge all csv files in one folder considering only 1 header row and ignoring header of all other files. FYI - All files are in same format and contains same headers. Thank you (4 Replies)
Discussion started by: Shiny_Roy
4 Replies

6. UNIX for Dummies Questions & Answers

append column and row header to a file in awk script.

Hi! Is there a way to append column and row header to a file in awk script. For example if I have Jane F 39 manager Carlos M 40 system administrator Sam F 20 programmer and I want it to be # name gend age occup 1 Jane F 39 manager 2 Carlos M ... (4 Replies)
Discussion started by: FUTURE_EINSTEIN
4 Replies

7. Shell Programming and Scripting

Add Header to column

hello, can someone helpe me on below issue. i have a list of names and IDs, mick 3424 noah 134 samuel 787 jack 434 i want to add a head for both colum using awk or sed or any tool output NAME ID mick 3424 noah 134 samuel 787 (10 Replies)
Discussion started by: Sara_84
10 Replies

8. Shell Programming and Scripting

Convert rows to column and add header

Hi, I need help to convert rows in input file into a table. inputfile 192.98.1 192.98.192.98.17 VVC family Zorro 10 192.98.1 192.98.192.98.17 VVC family Ace 1 192.98.1 192.98.192.98.17 VVC family ... (4 Replies)
Discussion started by: redse171
4 Replies

9. Shell Programming and Scripting

awk to skip header row and add string to field

The awk below does put in VUS in the 9th field but I can not seem to skip the header then add the VUS. I tried to incorporate NR >=2 and NR > 1 with no luck. Thank you :). input Chr Start End Ref Alt Func.refGene PopFreqMax CLINSIG Classification chr1 43395635 ... (5 Replies)
Discussion started by: cmccabe
5 Replies

10. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies
GSLP(1) 							    Ghostscript 							   GSLP(1)

NAME
gslp - Format and print text using ghostscript gsbj - Format and print text for BubbleJet printer using ghostscript gsdj - Format and print text for DeskJet printer using ghostscript gsdj500 - Format and print text for DeskJet 500 BubbleJet using ghostscript gslj - Format and print text for LaserJet printer using ghostscript SYNOPSIS
gslp -12BclqRr -b<header> -f<font> -F<hfont> -L<lines> -p<outfile> -T<n> --add-to-space <units> --add-to-width <units> --columns <n> --detect --first-page <n> --kern <file.afm> --last-page <n> --(heading|footing)-(left|center|right) <string> --margin-(top|bot- tom|left|right) <inches> --no-eject-(file|formfeed) --spacing <n> [gs options] [files] gsbj [options] [files] gsdj [options] [files] gsdj500 [options] [files] gslj [options] [files] DESCRIPTION
This utility provides functionality approximately equivalent to the Unix enscript(1) program. It prints plain text files using a single font. It currently handles tabs and formfeeds, but not backspaces. It will line-wrap when using fixed-pitch fonts. It will also do kern- ing and width adjustment. The default device (-sDEVICE=) and resolution (-r) are as follows: gslp epson 180 gsbj bj10e 180 gsdj deskjet 300 gsdj500 djet500 300 gslj laserjet 300 By default the current date is formatted as the center header. OPTIONS
Standard switches implemented: -12BclqRr -b<header> -f<font> -F<hfont> -L<lines> -p<outfile> Sun switches implemented: -T<n> set tab width Switches ignored: -GghKkmow -# -C -d -J -n -P -S -s -t -v Switches added: --add-to-space <units> add the given number of 1/72" units to the width of each space (may be negative) --add-to-width <units> add the given number of 1/72" units to the width of each character (may be negative) --columns <n> print in <n> columns --detect treat the file as PostScript if it starts with %! --first-page <n> start printing at page <n> --kern <file.afm> kern using information from the given .AFM file --last-page <n> stop printing after page <n> --(heading|footing)-(left|center|right) <string> set the heading/footing fields; use -B first to clear --margin-(top|bottom|left|right) <inches> set a margin --no-eject-(file|formfeed) end-of-file/FF only starts a new column, not a new sheet --spacing <n> use double (n=2), triple (n=3), etc. spacing Also, the string %# in a heading or footing is replaced with the page #. SEE ALSO
gs(1) VERSION
This document was last revised for Ghostscript version 9.07. AUTHOR
Artifex Software, Inc. are the primary maintainers of Ghostscript. This manpage by George Ferguson. 9.07 12 February 2013 GSLP(1)
All times are GMT -4. The time now is 10:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy