The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to make a line BLINKING in output and also how to increase font size in output mail2sant Shell Programming and Scripting 3 04-14-2008 08:30 AM
converting hex to dec aismann Shell Programming and Scripting 4 02-26-2008 05:51 AM
Converting gettimeoftheday output to string p_aishwarya UNIX for Dummies Questions & Answers 1 10-21-2007 10:13 AM
Converting \0 to a \n ajcannon Shell Programming and Scripting 2 09-28-2007 12:30 PM
sed converting / to \/ sakthi.abdullah UNIX for Advanced & Expert Users 8 12-14-2006 03:56 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-07-2008
Sreejith_VK
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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..
  #2 (permalink)  
Old 08-07-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
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 (permalink)  
Old 08-08-2008
Sreejith_VK
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Post

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 |
+-------------------+
  #4 (permalink)  
Old 08-08-2008
Sreejith_VK
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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.
  #5 (permalink)  
Old 08-08-2008
Sreejith_VK
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0