Help with awk alignment


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Help with awk alignment
# 1  
Old 03-01-2018
Help with awk alignment

Dear All,

I am in the beginning stage of learning shell scripting and preparing shell script on my own now.

I would like to get help from fellow mates here.

As I am trying to take O/P with space included from I/P table.

Kindly guide me to align given I/P table as Expected O/P.


Example:
I/P:

Code:
 4444  7777  0000
1111    3333    5555
aaaa    bbbb    cccc     dddd     eeee
xxxx    yyyy    zzzzz    bbbb    mmm
9999    8888    7777    6666    4444

Expected O/P:

Code:
4444
1111            
aaaa    dddd    eeee
xxxx    bbbb    mmm
9999    6666    4444


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 03-01-2018 at 04:32 AM.. Reason: Added CODE tags.
# 2  
Old 03-01-2018
Welcome to the forum.

Please specify exactly what you need and / or what you want to do so people in here don't need to guess from e.g. your output. Here it smells like "remove fields 2 and 3 from the input text file, outputting the result according to a non-given alignment."
Show your own attempts to solve the problem as well, even if they failed.

AND:

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

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

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
# 3  
Old 03-01-2018
Hi Rudic,

I am not allowed to disclose the data from my current organisation - UST Global Technologies and hence given sample data.
I am working on a script to take output from IBM MQ ffstsummary FDC files.
I have almost completed the script, but alignment problem still says with awk output.
I have attached exact sample data with this post that I am trying to achieve.

Given below code which created for my give task.

Code:
#!/usr/bin/ksh
dspmq | cut -d ")" -f1 | cut -d "(" -f2 > qmgr.txt
cat qmgr.txt | while read line
do
STATUS=`dspmq | grep $line | awk '{print $2}' | cut -d "(" -f2 | cut -d ")" -f1`
if [[  $STATUS == "Running" ]]
then
cd /var/mqm/errors
ffstsummary | awk '{print $1,$2,$4}' > "$line"_FDC_RECORD.txt
#mailx -s "$line"_FDC_RECORD.txt (mailID) < "$line"_FDC_RECORD.txt
fi
done


Moderator's Comments:
Mod Comment Seriously: Please use CODE tags as required by forum rules!
Help with awk alignment-awk1jpg

Last edited by RudiC; 03-01-2018 at 04:59 AM.. Reason: Added CODE tags.
# 4  
Old 03-01-2018
Which of the samples should we use for guessing your requirement? With the new one, it would be like "Remove ALL fields except 1, 2, and 4 RECOGNIZING some fields are empty"? How to detect empty fields? Or would that be every other field beyond field 2? What be the field separator in the last sample?
# 5  
Old 03-01-2018
Kindly consider my attached sample data with I/P , O/P & expected O/P.
Though vi editor I can move my cursor with each alphabet space with that complete space for field 2 and 4 under row 1 & 2.
# 6  
Old 03-01-2018
Hi Raja007. Could you please answer RudiC's questions?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Row alignment

*1 flash read test(*do_test1*) PASS *2 xxxxxxxxxxx flash write test(*do_test2) FAIL ------>xxxxx *1 flash read test(*do_test1*) PASS *2 xxxxxxxxxxx flash write test(*do_test2) FAIL ------>xxxxx I want pass and Fail to be aligned if each line uses printf or echo to print, is... (5 Replies)
Discussion started by: yanglei_fage
5 Replies

2. UNIX for Dummies Questions & Answers

awk code to reconstruct sequence from alignment

Hi Everyone, I need some help to construct a long 'Sbjct' string from the following input using incremental order of 'Sbjct' starting number (e.g. 26325115,33716368,33769033,34869860 etc.) Different 'Sbject' string will be separated by 'NNNN's as: ... (6 Replies)
Discussion started by: Fahmida
6 Replies

3. HP-UX

HP-UX text alignment

HI all, I tried to edit my files using HP-UX but my output tends to not align when I add another character in the files to edit my files i used the command is as follow chmod +w filename vi filename Help, :eek: (1 Reply)
Discussion started by: jasonhpwong
1 Replies

4. Shell Programming and Scripting

Output alignment problem

Hi Gurus, This is my raw data. How would I able to format this output into a better alignment? /dev/vg00/lvol5 /home 0.12 GB 0.02 GB 0.10 GB 19% /dev/vg00/misc /misc 28.43 GB 4.92 GB 23.51 GB 17% /dev/vg00/lvol6 /opt 8.25 GB 5.43 GB 2.82 GB 65% /dev/vgsap/ora10264 ... (10 Replies)
Discussion started by: superHonda123
10 Replies

5. Shell Programming and Scripting

alignment

Hi, I am having a file with with format. however, for longer xml, the xml code has been truncated like this. F1 |###################### |String1 |<XML><REQ><MSGTYPE>DBDIRECT</MSGTYPE><SYNC>0</SYNC><CLIENT>C11</CLIENT>NAME=MYNAME|JOB=MYJOB| | ... (3 Replies)
Discussion started by: shellwell
3 Replies

6. UNIX for Dummies Questions & Answers

VI paste out of alignment

We have a guy at work who is trying to copy and paste from one file to another using vi and highlighting the code to copy with a mouse. Source file: xyz 123 abc 999 zyx 321 cba 999 xyz 123 abc 999 But when he pastes it he gets (I put the underlines in to show... (4 Replies)
Discussion started by: dlam
4 Replies

7. Shell Programming and Scripting

alignment of variable

Dear Champs, i have a file let a.txt having value number text 00 123 012 145 456 ...etc i need number and text column vales should right align ??? how can i achive this ??? NOTE number is of max 3 char and text can take max 7 char...so if any records are less than above lengths... (2 Replies)
Discussion started by: manas_ranjan
2 Replies

8. UNIX for Dummies Questions & Answers

Column Alignment

I copied a word file to my Unix directory, How do I line up my columns to the file I copied over? (3 Replies)
Discussion started by: nikncha
3 Replies

9. Shell Programming and Scripting

PrintF and AWK => Center Alignment?

Alright, I'm relativly new to the Unix enviroment and C in general. I'm writing a script for AWK to search through a file and return what it finds with a center alignment, but so far, I can't get it to work. If anyone could help me out, I'd really appreciate it. (1 Reply)
Discussion started by: Mavrick3020
1 Replies
Login or Register to Ask a Question