Sponsored Content
Top Forums Shell Programming and Scripting how to introduce a space in a single column without distrubing the other columns Post 302366414 by ripat on Thursday 29th of October 2009 11:54:59 AM
Old 10-29-2009
It's easier when provided with a realistic sample file from the beginning.

Code:
$ cat f
col1 col2 AB11 col4
col1 col2 AB12 col4
col1 col2 C col4
col1 col2 CA col4
col1 col2 CB col4
col1 col2 AC1 col4
col1 col2 AC2 col4

$ awk 'length($3)==4{$3=substr($3, 4) substr($3,1,3)}length($3)<4{$3=" " $3}1' f
col1 col2 1AB1 col4
col1 col2 2AB1 col4
col1 col2  C col4
col1 col2  CA col4
col1 col2  CB col4
col1 col2  AC1 col4
col1 col2  AC2 col4

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

single column to multiple columns

Hello, I have a single column of data that I would like to cut/print (with awk or ...) into multiple columns at every empty row (or common character). Input: 5.99123 5.94693 7.21383 5.95202 0.907935 5.99149 6.08427 0.975774 6.077 Output: 5.99123 5.95202 6.08427 5.94693... (7 Replies)
Discussion started by: agibbs
7 Replies

2. Shell Programming and Scripting

Single column to multiple columns in awk

Hi - I'm new to the awk programming language. I'm trying to print a single column of data to several columns, and I found an article on iTWorld.com (ITworld.com - Printing in columns). It looks like the mkCols2 script is very close to what I need to do, but it looks like the end of the code... (2 Replies)
Discussion started by: astroDave
2 Replies

3. UNIX for Dummies Questions & Answers

How to convert a single column into several rows and columns?

I have a program which gives me the output as a single column with hundreds of rows like: 213 314 324 324 123 I want to be able to create a new file from this file which allows me to set the number of rows and columns in the new file, i.e. for this example, if I specify 3 rows and 2... (5 Replies)
Discussion started by: ashton_smith
5 Replies

4. Shell Programming and Scripting

Single command for add 2 columns and remove 2 columns in unix/performance tuning

Hi all, I have created a script which adding two columns and removing two columns for all files. Filename: Cust_information_1200_201010.txt Source Data: "1","Cust information","123","106001","street","1-203 high street" "1","Cust information","124","105001","street","1-203 high street" ... (0 Replies)
Discussion started by: onesuri
0 Replies

5. Shell Programming and Scripting

How to convert a single column into several columns?

Hi I have a ksh script which gives me the output as a single column with several rows like: AAA BBB CCC DDD EEE FFF GGG HHH III I want to be able to create a new file from this file which allows me to set the number of rows and columns in the new file, i.e. for this example, if I... (30 Replies)
Discussion started by: pinpe
30 Replies

6. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

7. Shell Programming and Scripting

Multiple columns to a single column

I have this input: 10 22 1 100 11 22 10 1 50 14 3 1 100 23 3 1 100 24 15 1 100 10 22 5 3 1 33.333 11 22 1 100 It has an inconsistent number of fields but the last field is determined by 100/(NF-2) using awk. I want to take this multiple columned input file and transform so that... (2 Replies)
Discussion started by: mdlloyd7
2 Replies

8. Shell Programming and Scripting

Transpose multiple rows (with a mix of space and enter) to a single column

How to change the uploaded weekly file data to the following format? New Well_Id,Old Well_Id,District,Thana,Date,Data,R.L,WellType,Lati.,Longi. BAG001,PT006,BARGUNA,AMTALI,1/2/1978,1.81,2.29,Piezometer,220825,901430 BAG001,PT006,BARGUNA,AMTALI,1/9/1978,1.87,2.29,Piezometer,220825,901430... (3 Replies)
Discussion started by: sara.nowreen
3 Replies

9. Shell Programming and Scripting

Insert space in specific column among many columns

Hello, I have some problem in inserting the space for the pairs of columns. I have the input file : I used this code below in replacing it using space in specific column (replace space in each two columns) sed -e "s/,/ /2" -e "s/,/ /3" inputfile Output showed : However, I have many... (3 Replies)
Discussion started by: awil
3 Replies

10. UNIX for Dummies Questions & Answers

How to generate one long column by merging two separate two columns in a single file?

Dear all, I have a simple question. I have a file like below (separated by tab): col1 col2 col3 col4 col5 col6 col7 21 66745 rs1234 21 rs5678 23334 0.89 21 66745 rs2334 21 rs9978 23334 0.89 21 66745 ... (4 Replies)
Discussion started by: forevertl
4 Replies
Gtk2::TreeStore(3)					User Contributed Perl Documentation					Gtk2::TreeStore(3)

NAME
Gtk2::TreeStore HIERARCHY
Glib::Object +----Gtk2::TreeStore INTERFACES
Gtk2::TreeModel Gtk2::TreeDragSource Gtk2::TreeDragDest Gtk2::TreeSortable Gtk2::Buildable METHODS
treestore = Gtk2::TreeStore->new (...) o ... (list) of strings, package names treeiter = $tree_store->append ($parent) o $parent (Gtk2::TreeIter or undef) $tree_store->clear $tree_store->set_column_types (...) o ... (list) of strings, package names $tree_store->set ($iter, $col1, $val1, ...) o $iter (Gtk2::TreeIter) o $col1 (integer) the first column number o $val1 (scalar) the first value o ... (list) pairs of columns and values treeiter = $tree_store->insert ($parent, $position) o $parent (Gtk2::TreeIter or undef) o $position (integer) treeiter = $tree_store->insert_after ($parent, $sibling) o $parent (Gtk2::TreeIter or undef) o $sibling (Gtk2::TreeIter or undef) treeiter = $tree_store->insert_before ($parent, $sibling) o $parent (Gtk2::TreeIter or undef) o $sibling (Gtk2::TreeIter or undef) treeiter = $tree_store->insert_with_values ($parent, $position, ...) o $parent (Gtk2::TreeIter or undef) o $position (integer) position to insert the new row o ... (list) pairs of column numbers and values Like doing insert followed by set, except that insert_with_values emits only the row-inserted signal, rather than row-inserted, row- changed, and, if the store is sorted, rows-reordered as in the multiple-operation case. Since emitting the rows-reordered signal repeatedly can affect the performance of the program, insert_with_values should generally be preferred when inserting rows in a sorted tree store. Since: gtk+ 2.10 boolean = $tree_store->is_ancestor ($iter, $descendant) o $iter (Gtk2::TreeIter) o $descendant (Gtk2::TreeIter) integer = $tree_store->iter_depth ($iter) o $iter (Gtk2::TreeIter) boolean = $tree_store->iter_is_valid ($iter) o $iter (Gtk2::TreeIter) Since: gtk+ 2.2 $tree_store->move_after ($iter, $position) o $iter (Gtk2::TreeIter) o $position (Gtk2::TreeIter or undef) Since: gtk+ 2.2 $tree_store->move_before ($iter, $position) o $iter (Gtk2::TreeIter) o $position (Gtk2::TreeIter or undef) Since: gtk+ 2.2 treeiter = $tree_store->prepend ($parent) o $parent (Gtk2::TreeIter or undef) boolean = $tree_store->remove ($iter) o $iter (Gtk2::TreeIter) $tree_store->reorder ($parent, ...) o $parent (Gtk2::TreeIter or undef) o ... (list) of integer's, the new_order Since: gtk+ 2.2 $tree_store->swap ($a, $b) o $a (Gtk2::TreeIter) o $b (Gtk2::TreeIter) Since: gtk+ 2.2 $tree_store->set_value ($iter, $col1, $val1, ...) o $iter (Gtk2::TreeIter) o $col1 (integer) the first column number o $val1 (scalar) the first value o ... (list) pairs of columns and values Alias for Gtk2::TreeStore::set(). SEE ALSO
Gtk2, Glib::Object COPYRIGHT
Copyright (C) 2003-2008 by the gtk2-perl team. This software is licensed under the LGPL. See Gtk2 for a full notice. perl v5.12.1 2010-07-05 Gtk2::TreeStore(3)
All times are GMT -4. The time now is 02:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy