Line count as 0000nn
This is going to sound like a stupid question but is it possible to carry out a line count of a file and display the count as 0000nn with 6 characters altogether.
eg. if line count is 1 -> 000001 if line count is 10 -> 000010 if line count is 100 -> 000100 etc. I need it in this format to place it in another file Thanks :) |
Try a script like this:
Code:
#!/bin/bash |
Quote:
Code:
wc -l filename | awk {'print $1'} | awk '{printf "%06s\n", $0}' |
Thanks Guys, sorry for not making it clearer.
I meant to do it from the command line. Thanks for the help |
Quote:
Please Mark the thread as solved (option is under Thread Tools on top menu), if you think it has so. |
Quote:
Code:
nl -nrz $InFile > $OutFile |
A couple of alternatives
Code:
wc -l file1.txt | awk '{printf "%06s\n", $1}' Also, printf is a bash cmd as well, so in a bash script Code:
s=2270 |
All times are GMT -5. The time now is 08:03 PM. |