Re: How to insert header and trailer in txt file using shell script
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- Date: 17 Aug 2006 08:54:38 GMT
On 16 Aug 2006 23:17:30 -0700, bonnie.tangyn@xxxxxxxxx wrote:
I used printf "%s\n" $(($wc -l < "$f.bak") + 2)) to append total number[...]
of rows in $f.bak and header and trailer at the end of the text file.
How can I put spaces in front of the outputed total number of rows?
For example:
output result: 504
it will put: ^^^^^^504 where ^ is space
output result: 2
it will put ^^^^^^^^2
How can I put space in front of the no. of rows automatically?
printf 'output result: %9d\n' "$number"
Or in awk:
printf "output result: %9d\n", number
$ printf '%9d\n' 1 11 111 1111
1
11
111
1111
You can use %9s instead if you want.
Differences are only about:
$ printf '%9s\n' 01
01
$ printf '%9d\n' 01
1
$ printf '%9d\n' 0x20
32
--
Stephane
.
- Follow-Ups:
- Re: How to insert header and trailer in txt file using shell script
- From: bonnie . tangyn
- Re: How to insert header and trailer in txt file using shell script
- References:
- How to insert header and trailer in txt file using shell script
- From: bonnie . tangyn
- Re: How to insert header and trailer in txt file using shell script
- From: Chris F.A. Johnson
- Re: How to insert header and trailer in txt file using shell script
- From: bonnie . tangyn
- Re: How to insert header and trailer in txt file using shell script
- From: Stephane Chazelas
- Re: How to insert header and trailer in txt file using shell script
- From: bonnie . tangyn
- How to insert header and trailer in txt file using shell script
- Prev by Date: Re: how to use unzip with pipe
- Next by Date: Regular expression issue in korn shell
- Previous by thread: Re: How to insert header and trailer in txt file using shell script
- Next by thread: Re: How to insert header and trailer in txt file using shell script
- Index(es):
Relevant Pages
|