Transposing a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Transposing a file
# 8  
Old 09-02-2008
Point taken. It works in ksh and the so-called POSIX sh shell.
# 9  
Old 09-02-2008
Well if transposing is what you want...why not use the transpose command?
Quote:
cat file|tr "\n" " "
# 10  
Old 09-02-2008
Quote:
Originally Posted by Annihilannic
Point taken. It works in ksh and the so-called POSIX sh shell.

The example I gave was in a standard POSIX shell; there it doesn't work.

If it works with /bin/sh, then /bin/sh is probably bash or ksh93.
# 11  
Old 09-02-2008
I was confused by this when I started to administrate HP-UX systems relatively recently. Their /bin/sh is distinct from the Bourne POSIX standard shell, it is apparently known as "the POSIX shell" and has a lot of ksh features (but not all). From the HP-UX 11.23 man page:

Quote:
The POSIX.2 standard requires that, on a POSIX-compliant system,
executing the command sh activates the POSIX shell (located in file
/usr/bin/sh on HP-UX systems), and executing the command man sh
produces an on-line manual entry that displays the syntax of the POSIX
shell command-line.

However, the sh command has historically been associated with the
conventional Bourne shell, which could confuse some users. To meet
standards requirements and also clarify the relationships of the
various shells and where they reside on the system, this entry
provides command-line syntax and a brief description of each shell,
and lists the names of the manual entries where each shell is
described in greater detail.

NOTE : The Bourne shell (/usr/old/bin/sh) is removed from the system
starting with HP-UX 11i Version 1.5. Please use the POSIX shell
(/usr/bin/sh) as an alternative.
What operating system were you testing on? The effect you see is what I'd have expected on Solaris, for example, where they seem to have a policy of retaining every piece of prehistoric paraphernalia they can (/usr/bin/awk is the one I find particularly frustrating).
# 12  
Old 09-02-2008
Quote:
Originally Posted by Annihilannic
I was confused by this when I started to administrate HP-UX systems relatively recently. Their /bin/sh is distinct from the Bourne POSIX standard shell, it is apparently known as "the POSIX shell" and has a lot of ksh features (but not all).

A lot of features in ksh are not part of the POSIX shell specification. This is one of them.
Quote:
What operating system were you testing on?

That is irrelevant. I was testing with a standard POSIX shell; I could have had the same result on many systems.

$(<filename) is not part of the POSIX specification; it is an extension implemented by some POSIX shells, primarily bash and ksh93.
# 13  
Old 09-02-2008
So it's safe to say that the /bin/sh that HP choose to call the POSIX shell is in fact a superset of POSIX, much like bash and ksh93.

I couldn't find the POSIX specification itself... unless SuSv3 is the same thing? I seem to find the terms used almost interchangeably. Anyway, as you say, SuSv3 says nothing about $(< ), nor does it mention brace expansion (test{1,2,3} becomes test1 test2 test3), which the shell in question also seems to support.

The Open Group -- the Single UNIX Specification Version 3

We digress. Smilie
# 14  
Old 09-02-2008
Quote:
Originally Posted by Annihilannic
So it's safe to say that the /bin/sh that HP choose to call the POSIX shell is in fact a superset of POSIX, much like bash and ksh93.

It probably is one of those two.

What does /bin/sh --version return?

Quote:
I couldn't find the POSIX specification itself... unless SuSv3 is the same thing?

Yes.
Quote:
I seem to find the terms used almost interchangeably. Anyway, as you say, SuSv3 says nothing about $(< ), nor does it mention brace expansion (test{1,2,3} becomes test1 test2 test3), which the shell in question also seems to support.

Then it must be bash (or a more recent version of ksh93 than I have).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Transposing a huge space delimited file

Hi, How do I transpose a huge space delimited file with more than 2 million columns and about 100 rows? Thanks! (10 Replies)
Discussion started by: evelibertine
10 Replies

2. Shell Programming and Scripting

Transposing lines in a csv file with sed

Hi I have a large csv file with lines like below Date,Status,orig,dest,in,out,when,where 2012-01-01 00:30:37,I,48,56,23,98,83,34 2012-06-17 15:00:38,I,72,43,12,65,34,12I will really appreciate if someone can help with a sed script to transpose this to 2012-01-01 00:30:37,I,orig,48... (5 Replies)
Discussion started by: kaf3773
5 Replies

3. Shell Programming and Scripting

Transposing a file

Hi Guys, I have file containing this kind of format below: ======== MOBILITY EVENT (G): ATTACH REJECT ========= Time : <date_time> Node : <node> GMM Cause : <code> Details : <details> Attach : <attach type> IMSI : <imsi> PTMSI : <ptmsi> RA New : <ra new> RA... (9 Replies)
Discussion started by: rymnd_12345
9 Replies

4. Shell Programming and Scripting

transposing square matrixs or blocks in a big file

Hi I do have a big file of the following format a b c d e f g 2 3 5 6 6 6 7 3 4 5 6 7 9 0 4 5 7 8 9 9 0 1 2 4 5 6 7 8 3 5 6 7 2 3 4 5 6 7 4 3 2 4 5 4 5 6 3 5 5 r h i j k l m 2 3 4 5 6 7 8 4 5 7 8 9 9 0 3 5 6 7 2 3 4 2 3 5 6 6 6 7 5 5 7 8 9 2 3 1 2... (7 Replies)
Discussion started by: Lucky Ali
7 Replies

5. Shell Programming and Scripting

Transposing a file

Hi All, I have a input file say FILEA. FILEA -------- empid1 sal1 location1 manager1 empid2 sal2 location2 manager2 empid3 sal3 location3 manager3 . . . (3 Replies)
Discussion started by: 46019
3 Replies

6. Shell Programming and Scripting

Transposing column to row, joining with another file, then sorting columns

Hello! I am very new to Linux and I do not know where to begin... I have a column with >64,000 elements (that are not in numberical order) like this: name 2 5 9 . . . 64,000 I would like to transpose this column into a row that will later become the header of a very large file... (2 Replies)
Discussion started by: doobedoo
2 Replies

7. UNIX Desktop Questions & Answers

More than transposing!

Hi everyone, I have a poblem like that: I have a file which includes data looks like: 0.65214 0.3597 1.0 0.65244 0.3502 1.0 0.65273 0.3553 1.0 0.65305 0.3544 1.0 0.65327 0.3505 1.0 0.65359 0.3516 1.0 0.65578 0.6464 1.0 0.65605 0.6453 1.0 0.65633 0.6437 1.0 0.65660 0.6488 1.0... (3 Replies)
Discussion started by: bulash
3 Replies

8. Shell Programming and Scripting

Another transposing issue

Hello I need to sort a file with data such as so it breaks on column 1 and all the data in column 2 is sorted into rows with a unique column 1: 1 5 1 6 1 7 2 3 2 4 3 7 3 0 3 9 So it comes out as: 1 5 6 7 2 3 4 3 7 0 9 I've tried many iterations of nawk but can't get it... (14 Replies)
Discussion started by: stevesmith
14 Replies

9. Shell Programming and Scripting

file transposing

Hello, Is there a way to transpose a file in shell scripting? For instance, from a1 a2 a3 a4 a5 a6 a7 .... b1 b2 b3 b4 b5 b6 b7 .... c1 c2 c3 c4 c5 c6 c7 .... d1 d2 d3 d4 d5 d6 d7 ... ... ... ... to a1 b1 c1 d1 .... a2 b2 c2 d2 .... a3 b3 c3 d3 .... a4 b3 c3 d4 .... ... ... (24 Replies)
Discussion started by: mskcc
24 Replies

10. Shell Programming and Scripting

transposing letters

Hi, I've written a shell function in bash that reads letters into an array, then outputs them in one column with: for n in "${array}"; do echo $n done I was wondering if anyone knew how i would transpose the letters that are output by the for loop. Right now my output is: aabbcc... (4 Replies)
Discussion started by: myscsa2004
4 Replies
Login or Register to Ask a Question