I had already tried column command and it is aligning the lines without "==>" also.
For example, if I have a line like below in my input.txt the output goes wrong.
cat input.txt
abc
qwert
qwer
afweferf
wdfwefwe ==> kjhjkwdd
mnmn ==> jkjkjwekj
poiu ==> lklklke
tytyutut ==> olkjmnsmn
This text need not be aligned.
column -t input.txt
abc
qwert
qwer
afweferf
wdfwefwe ==> kjhjkwdd
mnmn ==> jkjkjwekj
poiu ==> lklklke
tytyutut ==> olkjmnsmn
This text need not be aligned.
If I try column -s "==>" -t input.txt:
column -s "==>" -t input.txt
abc
qwert
qwer
afweferf
wdfwefwe kjhjkwdd
mnmn jkjkjwekj
poiu lklklke
tytyutut olkjmnsmn
This text need not be aligned.
The ==> is getting removed.
---------- Post updated at 08:06 AM ---------- Previous update was at 07:30 AM ----------
I just noticed one thing, the text before "==>" does not exceed 50 characters in max length. I think placing the ==> at exactly 50th character position should do the trick.
The general alignment program align provides a feature for processing only lines on which patterns match:
#!/usr/bin/env bash
# @(#) s1 Demonstrate align text for matched lines, align.
# For align code, see:
# http://freecode.com/projects/align
# Utility functions: print-as-echo, print-line-with-visual-space, debug.
# export PATH="/usr/local/bin:/usr/bin:/bin"
LC_ALL=C ; LANG=C ; export LC_ALL LANG
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
C=$HOME/bin/context && [ -f $C ] && $C align
FILE=${1-data1}
pl " Input data file $FILE:"
cat $FILE
pl " Results, align text only in lines in which \"==>\" appears:"
align -e "/==>/" $FILE
pl " Results, with a wider gutter:"
align -g 5 -e "/==>/" $FILE
exit 0
producing:
$ ./s1
Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution : Debian 5.0.8 (lenny, workstation)
bash GNU bash 3.2.39
align 1.7.0
-----
Input data file data1:
abc
qwert
qwer
afweferf
wdfwefwe ==> kjhjkwdd
mnmn ==> jkjkjwekj
poiu ==> lklklke
tytyutut ==> olkjmnsmn
This text need not be aligned.
-----
Results, align text only in lines in which "==>" appears:
abc
qwert
qwer
afweferf
wdfwefwe ==> kjhjkwdd
mnmn ==> jkjkjwekj
poiu ==> lklklke
tytyutut ==> olkjmnsmn
This text need not be aligned.
-----
Results, with a wider gutter:
abc
qwert
qwer
afweferf
wdfwefwe ==> kjhjkwdd
mnmn ==> jkjkjwekj
poiu ==> lklklke
tytyutut ==> olkjmnsmn
This text need not be aligned.
The code for align can be obtained from the URL noted in the first part of the script.