Search Results

Search: Posts Made By: adam1969in
2,368
Posted By MadeInGermany
With sed and a loop sed ' :L ...
With sed and a loop
sed '
:L
s/\([0-9]\{1,\}\),/ \1/
tL
' file
2,368
Posted By drl
Hi. Using the free utility align: ...
Hi.

Using the free utility align:
#!/usr/bin/env bash

# @(#) s1 Demonstrate automatic field alignment, align.

# Utility functions: print-as-echo, print-line-with-visual-space, debug....
2,368
Posted By Scrutinizer
Small correction: awk ' BEGIN { ...
Small correction:
awk '
BEGIN {
FS="!"; OFS="!"
}
{
for (i=1;i<=NF;i++) {
l=length($i)
gsub(/,/,x,$i)
$i=sprintf("%*s",l,$i)
}
print
}
' file
...
2,368
Posted By RudiC
sed might not be the tool of choice, then. Use...
sed might not be the tool of choice, then. Use either of the awk proposals and loop across the columns in question.
2,368
Posted By Scrutinizer
A different approach that should also work if...
A different approach that should also work if there is more than one thousands separator:
awk '{$4=sprintf("%*s",gsub(/,/,x,$4),x)$4}1' FS=! OFS=! file

--
x represents an empty string here. The...
2,368
Posted By Aia
awk -F! '{if(sub(",", "", $4)){$4=" "$4}}1' OFS=!...
awk -F! '{if(sub(",", "", $4)){$4=" "$4}}1' OFS=! adam1969in.file

sed 's/\([0-9]*\),/ \1/' adam1969in.file
perl -pe 's/(\d+),/ $1/' adam1969in.file
Showing results 1 to 6 of 6

 
All times are GMT -4. The time now is 08:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy