Sponsored Content
Top Forums Shell Programming and Scripting How to shuffle odd and even columns? Post 302957645 by cjcox on Tuesday 13th of October 2015 04:33:46 PM
Old 10-13-2015
off the top of my head:

Code:
awk '{
for (i=1;i<=NF;i++) {
    if (i%2) {
        oname=$i
    } else {
        ename=$i
        printf("%s_%s ",ename,oname);
    }
}

Doesn't preserve the white spacing though.
This User Gave Thanks to cjcox For This Post:
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shuffle pack of words in line

hello i just seeking for a simple way to make a shuffle by block of words in a line. no matter shell (sh/bash) or perl should be like this: the message (which is line of some file) splits to packs (packs are random 5-10 words in each) then making a new line inserting those packs in a random... (9 Replies)
Discussion started by: tip78
9 Replies

2. Shell Programming and Scripting

randomly shuffle two text files the same way

What I have are two text files that I need to shuffle randomly, but I need the two files to be randomly shuffled the same way. I have heard of shuf but I do not know how to use it for two files. Maybe there is also an easy/simple awk command I do not know about that could handle this problem. ... (3 Replies)
Discussion started by: adrunknarwhal
3 Replies

3. Homework & Coursework Questions

perl script card shuffle

Hi, I have a problem that pertains to using perl script pop,shift,push only to shuffle a card and print out 5 top listed numbers. HW problem from oreilly school of technology linux/unix course instructor name kelly hoover #!/usr/bin/perl @startingdeck = ("A H","2 H","3 H","4 H","5... (1 Reply)
Discussion started by: flyganji
1 Replies

4. Shell Programming and Scripting

Random shuffle of lines of a TXT file

Hello friends, I have a TXT file with 300 lines in it. I need to shuffle all the lines (randomly) so that they get into different order. Can anyone pls provide easy way, if any? I got it done by doing this below but I see it very lengthy/inefficient way. call random function to generate... (2 Replies)
Discussion started by: prvnrk
2 Replies

5. Shell Programming and Scripting

Shuffle Columns in Pipe delimited data

My sample data contains escape characters followed by delimiter. I'm stuck in writing awk comand to swap the columns. please help me out. Sample Data: 12345678|ABN\|XYZ MED CHEM PTY. LTD.|C||100.00|22|AB"C\|Corp|"XYZ|CDEF"| Expected Output Data: 12345678|C|ABN\|XYZ MED CHEM PTY.... (10 Replies)
Discussion started by: BrahmaNaiduA
10 Replies

6. Shell Programming and Scripting

Randomized shuffle words on each line

Hi Folks, I have a text file with a thousand lines consisting of words or a group of words separated by commas. I would like to randomize / shuffle the words on each line. Eg; file.txt Linux,Open,Free,Awesome,Best Things in Life,The Greatest Laptop,PC,Tablet,Home Computers,Digital... (2 Replies)
Discussion started by: martinsmith
2 Replies

7. UNIX for Beginners Questions & Answers

Logic shuffle

Hi, Is there any way I can shuffle the numbers randomly. I have been trying to google and I found lots of 'generator' but is it possible to find the background logic to create randomness? Thanks, (3 Replies)
Discussion started by: Indra2011
3 Replies
PR(1)							      General Commands Manual							     PR(1)

NAME
pr - print file SYNOPSIS
pr [ option ... ] [ file ... ] DESCRIPTION
Pr produces a printed listing of one or more files on its standard output. The output is separated into pages headed by a date, the name of the file or a specified header, and the page number. With no file arguments, pr prints its standard input. Options apply to all following files but may be reset between files: -n Produce n-column output. +n Begin printing with page n. -b Balance columns on last page, in case of multi-column output. -d Double space. -en Set the tab stops for input text every n spaces. -h Take the next argument as a page header (file by default). -in Replace sequences of blanks in the output by tabs, using tab stops set every n spaces. -f Use formfeeds to separate pages. -ln Take the length of the page to be n lines instead of the default 66. -m Print all files simultaneously, each in one column. -n Number the lines of each file. -on Offset the left margin n character positions. -sc Separate columns by the single character c instead of aligning them with white space. A missing c is taken to be a tab. -t Do not print the 5-line header or the 5-line trailer normally supplied for each page. -wn For multi-column output, take the width of the page to be n characters instead of the default 72. SOURCE
/sys/src/cmd/pr.c SEE ALSO
cat(1), lp(1) PR(1)
All times are GMT -4. The time now is 10:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy