Aligning data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Aligning data
# 1  
Old 09-16-2013
Aligning data

Hi Guys,
How can you align data getting the UID, GID HOSTNAME in same column

Code:
input:
 
server1
uid=1010(faculty) gid=700(teacher) groups=700(teacher), 800(models)
student:x:500:500:student:/home/student:/bin/bash

server2
uid=1010(OSAD) gid=700(teacher) groups=700(teacher), 809(staff)
student:x:500:500:student:/home/student:/bin/bash

OUTPUT:
Code:
HOSTNAME    UID   username        GID     GROUPS         OTHERGROUP
server1        1010    (faculty)      700       teacher          models

server2         1010    (OSAD)      700       teacher          staff

# 2  
Old 09-16-2013
How did you arrive at that output?
# 3  
Old 09-16-2013
Hi Scott,

If this is not possible.

Code:
HOSTNAME    UID   username        GID     GROUPS         OTHERGROUP
server1        1010    (faculty)      700       teacher          models

server2         1010    (OSAD)      700       teacher           staff

then this output is okay. something like a segregation
Code:
server1        1010    (faculty)      700       teacher          models

server2         1010    (OSAD)      700       teacher          staff


Last edited by Scott; 09-16-2013 at 11:35 PM.. Reason: Code tags
# 4  
Old 09-16-2013
Anything is possible, but I asked how you arrived at that output - what code you used to get the output.
# 5  
Old 09-16-2013
that is my desired output, i want it by sed or awk.
# 6  
Old 09-16-2013
You asked "how do I align my output?", not "can you write my script for me?", the answer to which, of course, is "no"!

Please post classroom or homework problems in the homework forum under the homework rules shown there.

Please also review the rules, which you agreed to when you registered, if you have not already done so.

Thank You.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Aligning Texts

is there any way to align my text so every column begins on the same line as the previous line? here's my command: printf "THEN ( ${SEARCHPATTB} = Hour = ${CALTOTB} ) %8s => %8s NOW ( ${SEARCHPATT} = Hour = ${CALTOT} ) %7s => %7s Reduced By: %7s -${RESULT}"\\n output i'm currently getting... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

Aligning a file

I have a large text file in following format cat input.txt abc qwert qwer afweferf wdfwefwe ==> kjhjkwdd mnmn ==> jkjkjwekj poiu ==> lklklke tytyutut ==> olkjmnsmn I need to align those lines with the characters " ==>" . I dont want to disturb the lines which dont have "==>". The... (6 Replies)
Discussion started by: ctrld
6 Replies

3. Shell Programming and Scripting

Aligning output with null fields in shell script

Hello Gurus ! I have what probably amounts to a few simply changes to fix; however for the life of me I cannot seem to get it ti work. I need to align the output of my script (I am writing to a logfile)... here's the lines in my code: if then echo "NODE: $node" >> $logfile... (6 Replies)
Discussion started by: gvolpini
6 Replies

4. UNIX for Dummies Questions & Answers

Help with Aligning the content of a txt file

Hello friends Please help me to display the content of a file in specific aligned manner. for ex. the content of the file may be >$TEST WELCOME HI HELLO UNIX SHELL SCRIPTING >$ I want to display the content like . TEST WELCOME HI HELLO ... (18 Replies)
Discussion started by: rajmohan146
18 Replies

5. Shell Programming and Scripting

Aligning columns in a text file using Perl

Hi All, I am new to perl and was trying to write a simple program which will generate a text file as output.. now the output which i am getting is something like this.. ================================================================================================== Col1 ... (8 Replies)
Discussion started by: smarty86
8 Replies

6. Shell Programming and Scripting

Aligning numbers in the second file based on first file

Hi All, I have two sets of files with names .dat and .txt. The number of files is really large more than 90000. The files have names like 1.dat, 2.dat,3.dat and so on where as txt files have names like 1.txt, 2.txt, 3.txt and so on The DAT and TXT files are equal in number. About 90000 each ... (4 Replies)
Discussion started by: shoaibjameel123
4 Replies

7. Shell Programming and Scripting

Aligning text files by max field length

Hello, Is there anyway that I can align a pipe delimited text file by the maxium field length where the field is separated out by pipes for large text files with more than 100,000 rows? So, far I have searched other forums and google about aligning text files in unix and I have noticed that... (7 Replies)
Discussion started by: physalis2099
7 Replies

8. Programming

Aligning for boundary conditions

Hi, I have tcp/ip client server programs which will communicate through reqest,reply c-structures. As the sizeof(struct) may give different value between client and server programs, how do i align properly for boundary conditions. Could anybody please give some suggestion. Thanks in... (3 Replies)
Discussion started by: axes
3 Replies

9. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

10. UNIX for Dummies Questions & Answers

Aligning Characters in Bash/Beautiful Screens

Howdy, Supposing I want to output the following code to the screen in a bash script, this works fine until you use variables as below, because the variable could be of any length, meaning the screen output for line 2 will have the ultimate # out of alignment. Is there a simple way round this?... (1 Reply)
Discussion started by: de_la_espada
1 Replies
Login or Register to Ask a Question