• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 497
  • Last Modified:

What is a one liner to get the second field of ls -la?

I'm looking for a perl one liner to get the second field using ls -la?
0
ckaspar
Asked:
ckaspar
1 Solution
 
clockwatcherCommented:
ls -la | perl -ne 'split; print "$_[1]\n";'
0
 
TalmashCommented:
other option is
ls -la | perl -ne '/^\s*\S+\s+(\S+)/&&print"$1\n"'
0
 
ozoCommented:
ls -la | perl -ne 'print /\S\s+(\S+)/,"\n"'
ls -la | perl -pe 's/\s*\S+\s+(\S+).*/$1/'
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now