Awk '{print $9}' the last ls -l column including any spaces in the file name?

A better solution: Don't attempt to parse ls output in the first place.

Up vote 2 down vote favorite 1 share g+ share fb share tw.

How would I get awk to output $9 $10 $11 etc as some of my files have spaces in them. Ls -l | grep ^- | awk '{print $9}' bash shell osx awk link|improve this question asked Sep 19 '09 at 5:09Mint63935 98% accept rate.

A better solution: Don't attempt to parse ls output in the first place. The official wiki of the irc.freenode.org #bash channel has an explanation of why this is a Bad Idea, and what alternate approaches you can take instead: mywiki.wooledge.org/ParsingLs Use of find, stat and similar tools will provide the functionality you're looking for without the pitfalls (not all of which are obvious -- some occur only when moving to platforms with different ls implementations). For your specific example, I'm guessing that you're trying to find only files (and not directories) in your current directory; your current implementation using ls -l is buggy, as it excludes files which have +t or setuid permissions.

The Right Way to implement this would be the following: find . -maxdepth 1 -type f -printf '%f\n.

2 Consider the use of \0 in place of \n if you're feeding the output into another command like grep -z or xargs -0. This makes -printf work like -print0. – Dennis Williamson Sep 19 '09 at 7:22.

There's probably a better approach that involves combining fields somehow, but: $ echo 1 2 3 4 5 6 7 8 9 10 11 12 13 14... | awk '{for (i = 9 ; I.

Echo 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 | awk 'BEGIN {OFS=ORS=""} ; {for (i=9;i.

If you still insist on the ls -l instead of find or other tools, here is my solution. It is not pretty and destructive: Destroy $1 .. $8 by setting them to "" via a for loop That leaves a bunch of spaces preceding $9, remove them using the sub() command Print out the remaining ls -l | awk '{for (i = 1; I.

Just for completion. It can also be done with sed: # just an exercise in regex matching ... ls -l | sed -E -e 1d -e /^^-/d -e 's/^(^ + +){8}.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions