Hello all,
I want to list the file contents of the directory and number them. I am using la and awk to do it now,
#ls |awk '{print NR "." $1}'
- alpha
- beta
- gamma
The problem I have is that some files might also have some spaces in the filenames.
#ls
alpha beta gamma some file with spaces.txt
Now I want it this way
- alpha
- beta
- gamma
- some file with spaces.txt
How do I do it?
printf '%s\n' *|nl
If the format is important:
printf '%s\n' *|nl -w1 -s.
I need something like this
Filename 1 is alpha
Filename 2 is beta
Filename 3 is gamma
Filename 4 is some file with spaces.txt
awk 'BEGIN {
while (++i < ARGC)
printf "Filename %d is %s\n", i, ARGV
}' *
Lets say, I have 3 files in a directory
#ls
alpha
beta
file with spaces
Now I want to list them in the following manner
<LI><A href="alpha">alpha</A>
<LI><A href="beta">beta</A>
<LI><A href="file with spaces">file with spaces</A>
I tried this,
ls |awk '{ print "<LI><A href=\" "$1" \"> " $1 "</A>"}'
It works fine for the files without spaces but only pickes up the first word of the file with spaces.
I know that I am doing it wrong, but am not sure of the corrected method. Please help.
ls |awk '{ print "<LI><A href=\" "$0" \"> " $0 "</A>"}'
I would avoid to use external commands (ls) in this case,
AWK can do it all :).
awk 'BEGIN {
while (++i < ARGC)
printf "<LI><A href=\"%s\">%s</A>\n", ARGV, ARGV
}' *
Thank you both of you!!!!
:):):)