New Trick Learned
Learned a new trick from the Shell Programming and Scripting from Unix and Linux Forum. Suppose you need to convert a single column file to multi-column with colon(:) as separator
$cat a one two three four five six seven eight nine ten eleven twelve $cat a | paste -d: - - - one:two:three four:five:six seven:eight:nine ten:eleven:twelve $cat a | paste -d: - - - - one:two:three:four five:six:seven:eight nine:ten:eleven:twelve $cat a | paste -d: - - - - - - one:two:three:four:five:six seven:eight:nine:ten:eleven:twelve
In Unix, if "-" is specify as the file input, it will take the input from the pipe. In our case, multiple "-" in the paste will consume input one line at a time. Just a recap, I blogged about paste command in Solaris has a limit of no more than 12 files
$(cat a a a) | paste -d: - - - - - - - - - - one:two:three:four:five:six:seven:eight:nine:ten eleven:twelve:one:two:three:four:five:six:seven:eight nine:ten:eleven:twelve:one:two:three:four:five:six seven:eight:nine:ten:eleven:twelve:::: $(cat a a a) | paste -d: - - - - - - - - - - - - one:two:three:four:five:six:seven:eight:nine:ten:eleven:twelve one:two:three:four:five:six:seven:eight:nine:ten:eleven:twelve one:two:three:four:five:six:seven:eight:nine:ten:eleven:twelve $(cat a a a) | paste -d: - - - - - - - - - - - - - - paste: too many files- limit 12
Labels: shell script, Solaris
0 Comments:
Post a Comment
<< Home