Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Split a column into multiple columns at certain character count Post 302810951 by Yoda on Wednesday 22nd of May 2013 06:54:33 PM
Old 05-22-2013
Have you tried using fold for wrapping each input line to fit in specified width?

Check the man page:
Code:
man fold

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to split a text after fix character count

HI, I want to split a text after certain fix character count in text. For eg: My file is containing text like: AURBJR,AURCID,AURVID,CHANDV,DAMNEW,DHMMAN,GANGAN,GARKHE,GOREGA,JEJKHA,JEJSHI,JINTUR,JMKKUS,JUNAWA,KALKAL,KHOJEW,KUNJIR,MAGARP,MAHAD, in this i want to print text after each... (5 Replies)
Discussion started by: vikash.rastogi
5 Replies

2. Web Development

split the fields in a column into 3 columns

Have a column "address" which is combination of city, region and postal code like. Format is : city<comma><space>region<space>postal code abc, xyz 123456 All these three city, region and postal code are not mandatory. There can be any one of the above. In that case a nell... (2 Replies)
Discussion started by: rakshit
2 Replies

3. UNIX for Dummies Questions & Answers

split one column into multiple columns

hey guys... Im looking to do the following: 1 2 3 4 5 6 7 8 9 Change to: 1 4 7 2 5 8 3 6 9 Did use | perl -lpe'$\=$.%3?$":"\n"' , but it doesnt give me the matrix i want. (3 Replies)
Discussion started by: zaneded
3 Replies

4. Shell Programming and Scripting

split one column into multiple columns

hey, i have the following data: 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 (7 Replies)
Discussion started by: zaneded
7 Replies

5. Shell Programming and Scripting

Count Columns and If less add new column

Hi All, My Input.txt should have always 4 columns in some cases i may not get all the 4columns data. My requirement is if columns as not equal to 4 then append new column delimiter. Input.txt A,1,2 B,1,2,3 C,1 Desired output should be in below format Output.txt A,1,2,... (3 Replies)
Discussion started by: kmsekhar
3 Replies

6. Shell Programming and Scripting

Split text separated by ; in a column into multiple columns

Hi, I need help to split a long text in a column which is separated by ; and i need to print them out in multiple columns. My input file is tab-delimited and has 11 columns as below:- aRg02004 21452 asdfwf 21452 21452 4.6e-29 5e-29 -1 3 50 ffg|GGD|9009 14101.10 High class -node. ; ffg|GGD|969... (3 Replies)
Discussion started by: redse171
3 Replies

7. Shell Programming and Scripting

How to split all columns into multiple columns?

Hi, all. How can I split all columns into multiple columns separated by tab? Input: qq ee TT 12 m1 aa gg GG 34 2u zz dd hh 56 4h ww cc JJ 78 5y ss ff kk 90 j8 xx pp mm 13 p0 Output: q q e e T T 1 2 m 1 a a g g G G 3 4 2 u z z d d h h 5 6 4 h w w c c J J 7 8 5 y (8 Replies)
Discussion started by: huiyee1
8 Replies

8. UNIX for Dummies Questions & Answers

Split 1 column into numerous columns based on patterns

Hi, I have a text file 'Item_List.txt' containing only 1 column. This column lists different products, each separated by the same generic string header "NEW PRODUCT, VERSION 1.1". After this the name of the product is given, then a delimiter string "PRODUCT FIELD", and then the name of the... (11 Replies)
Discussion started by: mmab
11 Replies

9. Shell Programming and Scripting

awk split columns to row after N number of column

I want to split this with every 5 or 50 depend on how much data the file will have. And remove the comma on the end Source file will have 001,0002,0003,004,005,0006,0007,007A,007B,007C,007E,007F,008A,008C Need Output from every 5 tab and remove the comma from end of each row ... (4 Replies)
Discussion started by: ranjancom2000
4 Replies

10. UNIX for Beginners Questions & Answers

Using awk to split a column into two columns

Hi, I am trying to split the following output into two columns, where each column has Source: Destination: OUTPUT TO FILTER $ tshark -r Capture_without_mtr.pcap -V | awk '/ (Source|Destination): /' | more Source: x.x.x.x Destination: x.x.x.x Source:... (2 Replies)
Discussion started by: sand1234
2 Replies
fold(1) 						      General Commands Manual							   fold(1)

NAME
fold - Breaks or wraps lines in a file SYNOPSIS
fold [-bs] [-w width | -width] [file...] The fold command wraps lines in the specified files. If a file is not specified, standard input is the default. All lines are wrapped to meet the maximum width specified. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: fold: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
Specifies that width be counted in bytes rather than in column positions. Using the -b option does not limit lines to LINE_MAX bytes. Breaks (or wraps) a line if a segment of the line contains a blank character in the first width column position (or bytes). This enables the line to meet width constraints. If a blank character is not in the correct width column position, the -s option has no affect on that input line. Specifies the maximum width to use when lines are wrapped in column positions (or bytes if the -b option is specified). Either -w width or -width is acceptable input where width is the number of column positions (or bytes). The default value is 80. DESCRIPTION
The fold command is a filter that wraps lines from the specified input files or standard input to a maximum of width (or bytes, if the -b option is specified). The fold command wraps lines by inserting a newline character into the output so that each output line is the maxi- mum column positions or bytes specified. A line cannot be broken in the middle of a character. The fold command is often used to send text files to line printers that truncate, rather than wrap, lines wider than the printer is able to print (usually 80 or 132 column positions). If the <backspace>, <tab>, or <carriage return> characters are encountered in the input, and the -b option is not specified, these charac- ters are treated specially: The current count of line width is decremented by one, although the count never becomes negative. The fold command does not insert a newline character immediately before or after any backspace character. Each tab character encountered advances the column position pointer to the position of the next tab stop. Tab stops are at each column position number, such that number modulo 8 equals 1. The current count of the line width is set to zero (0). The fold command does not insert a newline immediately before or after any carriage return. [Tru64 UNIX] The fold command possibly affects underlining in a file. EXIT STATUS
The fold command returns the following values: All input files were successfully processed. [Tru64 UNIX] A usage error occurred. [Tru64 UNIX] An input file cannot be opened. The fold command continues processing the other input files specified on the command line. EXAMPLES
The fold command can be used to prepare files to be joined side-by-side with the paste command. For example, the contents of two files, az and AZ follows: aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH IIII JJJJ KKKK LLLL MMMM NNNN OOOO PPPP QQQQ RRRR SSSS TTTT UUUU VVVV WWWW XXXX YYYY ZZZZ To display the az and AZ files side-by-side, use the following command line: fold -w 32 az > az2; fold -w 32 AZ > AZ2; paste -d" " az2 AZ2 Executing the previous command line results in the following output: aaaa bbbb cccc dddd eeee ffff gg AAAA BBBB CCCC DDDD EEEE FFFF GG gg hhhh iiii jjjj kkkk llll mmmm GG HHHH IIII JJJJ KKKK LLLL MMMM nnnn oooo pppp qqqq rrrr ssss tt NNNN OOOO PPPP QQQQ RRRR SSSS TT tt uuuu vvvv wwww xxxx yyyy zzzz TT UUUU VVVV WWWW XXXX YYYY ZZZZ ENVIRONMENT VARIABLES
The following environment variables affect the execution of fold: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments) and for the determination of the width in column positions each character would occupy on a constant-width font output device. Determines the locale for the format and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MES- SAGES. SEE ALSO
Commands: cut(1), expand(1), paste(1) Standards: standards(5) fold(1)
All times are GMT -4. The time now is 07:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy