I have a config file that contains some text as below:
Can anyone advise how is the best way to be able to format the text so that they lined up neatly?
At the moment, am doing it manually. Thinking I should use awk and printf using the max string of each column as the basis for the max length of the column for each field. Using space seems to be better than using tab as well.
Hi newbie_01,
Your request isn't clear as to whether the field separator in your input is supposed to be the colon character or sequences of space characters. The suggestions you have from pamu and mjf made different assumptions. The sed script proposed by pamu will line up the 1st, 2nd, 3rd, and 4th fields in the output; but not the 5th field. The awk script provided by mjf will line up all of the columns, but still requires that someone manually determine the maximum width of each field and enter those values into the widthlist string in the script.
The following awk script will calculate the width of each field without manual intervention.
When the file in contains your input data, and this script is run, the output produced is:
As written the script uses ":" as the field separator. If you change the 2nd line in the file from:
to:
and rerun the script (using the default field separators), the output produced is:
Hopefully, one of these will meet your needs.
This User Gave Thanks to Don Cragun For This Post:
Oops, sorry forgot to mention the most important piece of information. The field separator is the colon ( ... I'll try your suggestions and hopefully all goes well.
I have a text file which is generated when the batch job is run. This batch may take few mins to run. When completed, the last line of the text file would be process completed. I need a shell script which will wait for this file till the process completed is printed in it, once found, it would move... (2 Replies)
Hi,
I have been searching for a tool or online URL to format (beautify) UNIX shell script without any luck.
Could you please assist any online link or tool to format UNIX shell script.
I've couple of legacy scripts needs to be formatted.
Thank you in advance.
Regards,
Pointers (4 Replies)
Hello Forum.
I have a file called abc.sed with the following commands;
s/1/one/g
s/2/two/g
...
I also have a second file called abc.dat and would like to substitute all occurrences of "1 with one", "2 with two", etc and create a new file called abc_new.dat
sed -f abc.sed abc.dat >... (10 Replies)
I have file which contains a huge amount of data. I need to search the pattern Message id. When that pattern is matched I need to get abcdeff0-1g6g-91g3-1z2z-2mm605m90000 to another file.
Kindly provide your input.
File is like below
Jan 11 04:05:10 linux100 |NOTICE... (2 Replies)
Hello everyone
I am completely new to shell scripting in linux. I wan to write a script to search for a certain string from a .txt file and copy the string which apears just after tat searched string.
Eg: in a file- try.txt , we have a line saying: "roses are red, so what do i do"
I... (4 Replies)
Hello,
I have a file whose contents look as follows
<ID="24" name="Kobe Bryant" Position="Shooting Guard">
<name="Artest" Position="Forward" ID="37">
I need to get the output which contains everything in the quotes for Position (Shooting Guard and Forward). I tried this but it doesn't work... (3 Replies)
hello,
do anybody know a program to format a shell script code ?
i tried "editrocket.com" but this product doesn't format a shell script code.
i searched for programs but can't find a shell script code formatter.
i have to change a shell script and the style of code is .....
regards (5 Replies)
HI all,
Is their any UNIX shell script code formatter that work on windows ?
If so where can I get it ?
I want to format the shell scripts in with proper indentation etc...
Thanks...In Advance (0 Replies)