Converting to columnar output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Converting to columnar output
# 1  
Old 08-07-2008
Converting to columnar output

Hi All,

I need some help in script or awk to create a textfile.

I have a directory where two subdirectories exists say A and B.
Now I need to write a ".txt" file with well arranged(space wraped) three columns in it with the data as follows:

1st column:Serial number(which will increment with the row number)
2nd column:With the filenames of those files existing inside directory A (I do have subfolders inside A)
3rd column:With the filenames of those files existing inside directory B (here also same problem, I have subfolders inside B).

I tried outputing ls * and manipulating .. but was stuck in subfolders..
Sreejith_VK
# 2  
Old 08-07-2008
Question Can you provide an example of input/output?

If this is the input...
(think of nesting as in the directory structure)
Code:
animals
  humans
    Joe
    John
    Mary
  dogs
  cats
fruits
  apples
    red
    granny
  banana

then output =
????
# 3  
Old 08-08-2008
Java

INPUT:

Quote:
root directory-->animals
Subdirectory A--> humans
File ---> Joe
File ---> John
File ---> Mary
subsub directoryof A-->dogs
file ----> Blacky
subsub directoryof A-->cats
file ---->snowy
Subdirectory B-->fruits
File ---> apples
File ---> red
File ---> granny
subsub directoryof B-->banana
File---> banana1
Now the output is I require:-

Quote:
+-------------------+
|1 Joe apples |
|2 John red |
|3 Mary granny |
|4 Blacky banana1 |
|5 snowy |
+-------------------+
Sreejith_VK
# 4  
Old 08-08-2008
Now I am able to get all the output.
Only thing remaning is arranging them into three columns.

What I have done is something like this:

Code:
find /animals/humans -type f|awk -F/ '{print $NF}'>animals.lst

find /animals/fruits -type f|awk -F/ '{print $NF}'>fruits.lst

Thanks in anticipation.
Sreejith_VK
# 5  
Old 08-08-2008
Convert to columns

if u have a data:

Quote:
5446565
1212213
245632

hello.txt
howru.txt

Iamfine.txt
thanks.txt
howabtu.txt
then result shud be like:
Column1 Column2 Column3
--------- -------- ----------
Quote:
5446565 hello.txt Iamfine.txt
1212213 howru.txt thanks.txt
245632 ---------- howabtu.txt

That is using the three blank lines I want to separate the column to three.
Sreejith_VK
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Joining Columnar heading from 2 lines

Hi, Below is the format of a report generated by a custom reporting solution. I opened the report in Notepad++ and junked data and values as in the image below. https://www.unix.com/attachment.php?attachmentid=7907&stc=1&d=1575507708 I want to convert the values to a PIPE delimited format as... (2 Replies)
Discussion started by: ramkrix
2 Replies

2. Shell Programming and Scripting

Linear Interpolation of CSV Columnar Data

I am trying to perform linear interpolation on three columns in a CSV file. When I run this code, I do not get any changes in the output (see Expected Output). What am I doing wrong here? Awk Code ' function interpolate(lat1, lon1, t1, lat2, lon2, t2, i) { for (i = 1; i... (2 Replies)
Discussion started by: hrrruser
2 Replies

3. Shell Programming and Scripting

Need Help in converting

I have Excel file with the below three columns, i need your expertise in converting this to .csv file delimiter "|" Excel - Serial Number Serial Name Serial Brand 111 test sample 123 test2 sample1 134 ... (9 Replies)
Discussion started by: kiran_hp
9 Replies

4. UNIX for Dummies Questions & Answers

Converting txt output to rows and columns and send report via mail.

Hi All, I would like to send below output in a tabular column ( xml or excel ) and send a mail. vinay unix anil sql vamsee java request to suggest a solution. (1 Reply)
Discussion started by: Girish19
1 Replies

5. Ubuntu

Converting Impress output to DVD video

I have a need to convert 'Impress' presentations to DVD video format whilst retaining the original presentation in situ. Copying the individual slides and modifying size etc. in Gimp and then importing them into 'Openshot' is both long winded and the loss of quality is significant. Can anybody... (14 Replies)
Discussion started by: Royalist
14 Replies

6. Shell Programming and Scripting

Need help converting df output to gigabytes

I need some help converting the disk space values in kilobytes to gigabytes. I can't use df -h because the report has to be in megabytes for some disk space tracking software the customer is using. I have been playing around with trying to assign variables I can use outside of awk so I can do... (1 Reply)
Discussion started by: kuliksco
1 Replies

7. Shell Programming and Scripting

File Comparison Columnar?

I'm looking to build up a process which would compare 2 files and show difference, the difference needs to be done in such a way that it also shows which column value is differing. So i think of this. Run a diff between the files , then someway find which columns have different values need to... (6 Replies)
Discussion started by: dinjo_jo
6 Replies

8. Shell Programming and Scripting

Converting line output to column based output

Hi Guys, I am trying to convert a file which has a row based output to a column based output. My original file looks like this: 1 2 3 4 5 6 1 2 3 1 2 3 (8 Replies)
Discussion started by: npatwardhan
8 Replies

9. UNIX for Dummies Questions & Answers

Converting gettimeoftheday output to string

Hi .. is there a way i can retrieve the output of gettimeoftheday in a string (1 Reply)
Discussion started by: p_aishwarya
1 Replies

10. UNIX for Dummies Questions & Answers

converting kb to mb

When I create filesystems in AIX i often get confused(using smit) When you specify size in aix, it is asked like this SIZE of file system (in 512-byte blocks) I never seem to grasp this, what is the equation to get say 500mb? Or is there a program anyone knows of that does this, like a... (1 Reply)
Discussion started by: csaunders
1 Replies
Login or Register to Ask a Question