I have a file like this :
I have used sed to remove the thousands separator
The column of amount now gets mis-aligned, like this :
The numbers with thousands separator gets shifted one space left. And if the numbers are in lakhs, the more it shifts to the left. I need the output like this :
Please help me to do it either using sed or awk. I prefer awk
Last edited by adam1969in; 04-07-2017 at 11:40 PM..
Reason: spelling mistake
A different approach that should also work if there is more than one thousands separator:
-- x represents an empty string here. The number of comma replacements (gsub) determine the amount of space padding to the left.
--
As an alternative, if the column width is known beforehand, then one could also use:
If it is not, it can be determined like this:
--
Note:
The locale's thousands separator number parsing is broken in many applications, so the value needs to be treated as a string instead of a number. For example bash and awk fail to interpret the number in column 4 correctly..
ksh93 for one does it perfectly however (with the right locale):
Last edited by Scrutinizer; 04-08-2017 at 09:34 AM..
This User Gave Thanks to Scrutinizer For This Post:
Hello;
I have a simple loop filtering a log:
for LU in $(< LU-list-Final)
do
OUT=$(grep -B1 $LU cibc-src-ip.cap |egrep 'IP 16|IP 19|IP 15' |awk -F">" '{print $1}')
if ; then
echo " LU $LU was accessed by ===============> $OUT "
echo ""
fi
done
The current output snippet looks like... (2 Replies)
When i execute the below shell script with 2 different Input files, for one of the data files (datafile1) my email message body in the outlook messes up and every thing comes up in one line. May i please know what i am doing wrong here or how to fix this? The only difference in data files is one is... (1 Reply)
I have file, i am extracting email address from file. but problem is that output is very ugly.
I am using this command
REMOVED "CSS OFFENDING CODE"...
While original filename have no such character. Please suggest. (20 Replies)
:oi was trying to write a script to format output of a command in ksh which has output as below:
so i used :
to get
which i require at all times. But problem occurs when status part changes. above output i get when status is SU (success).If the status is IN (inactive), output of... (1 Reply)
Hi there. I have a very large file and I am trying to format it so that I can pull out certain pieces of data/info and report it in spreadsheet format/style.
The file has ###### which will separate each line that will be listed in the spreadsheet. Whenever I find "No" at the end of a line I want... (7 Replies)
Hi;
i m running an command like;
getfacl $(find /home/fstl/testShell/ -type f -ls | awk '{print $11}')
and i m getting outpiut for all files in "testShell" folder as;
# file: home/fstl/testShell/.script1.sh.swp
# owner: root
# group: root
user:fstl:rw-
user:ajay:rw-
group:root:r--... (1 Reply)
# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
How would i write a script to display permission on each folders in $PATH variable below format.
drwxr-xr-x 2 0 root 4096 Nov 24 14:51 /usr/kerberos/sbin
drwxr-xr-x 2 0... (2 Replies)
I would like to keep the complete lines in the output, but my script adds carriage returns for each space (e.g. keep BRITISH AIRWAYS on one line in the output):
File1=
BAW
BRITISH AIRWAYS
RYR
RYAN AIR
for i in $(cat File1)
do
echo $i
done
Output:
BAW
BRITISH
AIRWAYS
RYR... (4 Replies)
Hi guys,
It will be a great help if somebody can help me in following problem.
I have tried hard but because of lack of UNIX/LINUX knowledge I am not able to do it.
I have written a script that returns 3 things of all the employees in my organisation. i.e. Name, Login time & log out time of... (2 Replies)