Changing data format from column into array


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Changing data format from column into array
# 8  
Old 10-19-2012
Quote:
Originally Posted by ShiGua
Sorry, just checking. cols will be the number of entries in each column right? Not the number of columns? And what's the $1 for?
$1 is the first field of the file..
# 9  
Old 10-19-2012
I suppose a simple shell script could count lines read and print thos modulo 100 = 1, 2, or 0.
Code:
ct=0
while read l
do
 if (( ct % 100 == 1 ))
 then
  echo "$l"
 fi
done <in_file

If you don't like/have pipes <(...), you can collect each 300 lines in an array and print them out in your order.

You could prefix each line with the order you need them in (1, 4, 7, . . . 298, 2, 5, 8, . . . 299, 3, 6, 9, . . . 300, 301, 304, . . . .), sort -n them all and process the output three lines into one:
Code:
while read n l1
do
 read n l2
 read n l3
 echo "$l1 $l2 $l3"
done

It'd make a handy C app, just give it a width and length, and it can fputs the M lines to N tmpfile() FILE*'s, rewind, print, rewind, repeat.

Last edited by DGPickett; 10-19-2012 at 06:00 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Presenting data in column format

I have written a script that that takes file names and breaks them apart. File names are : aal_mock.war.deployed AuroralMockService-1.0.war.deployed consumerProfile.war.deployed EbillMock.war.deployed IAMAOGServices.war.deployed IAMPermission.war.deployed... (5 Replies)
Discussion started by: Junaid Subhani
5 Replies

2. Shell Programming and Scripting

Changing values only in 3rd column and 4th column

#cat file testing test! nipw asdkjasjdk ok! what !ok host server1 check_ssh_disk!102.56.1.101!30!50!/ other host server 2 des check_ssh_disk!192.6.1.10!40!30!/ #grep check file| awk -F! '{print $3,$4}'|awk '{gsub($1,"",$1)}1' 50 30 # Output: (6 Replies)
Discussion started by: kenshinhimura
6 Replies

3. UNIX for Dummies Questions & Answers

Des/awk for change format and adding integers in a column of data?

Greetings! I need a quick way to change the format in a table of data Here is an example of the input: 10 72 Value=177 VDB=0.0245 Value4=0,0,171,0 10 274 Value=238 VDB=0.0433 Value4=29,0,205,0 10 312 Value=222 VDB=0.0384 Value4=8,0,190,19 10 540 Value=405 VDB=0.0391 Value4=13,30,153,195... (3 Replies)
Discussion started by: Twinklefingers
3 Replies

4. Shell Programming and Scripting

awk - script help: column to row format of data allignment?

Experts Good day, I have the following data, file1 BRAAGRP1 A2X B2X C2X D2X BRBGRP12 A3X B3X Z10 D09 BRC1GRP2 LO01 (4 Replies)
Discussion started by: rveri
4 Replies

5. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

6. Shell Programming and Scripting

Sort a the file & refine data column & row format

cat file1.txt field1 "user1": field2:"data-cde" field3:"data-pqr" field4:"data-mno" field1 "user1": field2:"data-dcb" field3:"data-mxz" field4:"data-zul" field1 "user2": field2:"data-cqz" field3:"data-xoq" field4:"data-pos" Now i need to have the date like below. i have just... (7 Replies)
Discussion started by: ckaramsetty
7 Replies

7. Shell Programming and Scripting

Convert array data to excel format

I need your help in changing the script I have data has below text file :> cat my_emp Employee array(0) Name : Albert No : 1234 Address: stationstraat City: Utrecht Employee array (1) Name : Kouwen No : 1256 Address: stationstraat City: Amsterdam Employee array (2) Name : Peter... (2 Replies)
Discussion started by: LinuxLearner
2 Replies

8. Shell Programming and Scripting

Changing one column of delimited file column to fixed width column

Hi, Iam new to unix. I have one input file . Input file : ID1~Name1~Place1 ID2~Name2~Place2 ID3~Name3~Place3 I need output such that only first column should change to fixed width column of 15 characters of length. Output File: ID1<<12 spaces>>Name1~Place1 ID2<<12... (5 Replies)
Discussion started by: manneni prakash
5 Replies

9. Shell Programming and Scripting

Format - Inventory Row data into Column - Awk - Nawk

Hi All, I have the following file that has computer data for various pcs in my network... Snap of the file is as follows ******************************************************************************* Serial 123456 Computer IP Address lo0:... (1 Reply)
Discussion started by: aavam
1 Replies

10. Shell Programming and Scripting

changing month in Mmm format to mm FORMAT

i have an variable mydate=2008Nov07 i want o/p as in variable mymonth=11 (i.e nov comes on 11 number month) i want some command to do this for any month without using any loop. plz help me (1 Reply)
Discussion started by: RahulJoshi
1 Replies
Login or Register to Ask a Question