The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-08-2008
DNAx86 DNAx86 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 69
ls AND cut

Hi,

this is a small script, it should print on the screen only the 3rd colum of ls -laR, so where there are the user's permissions, but, if the script is:

permission=rw-r--r--
ls -laR | grep "^-$permission" | cut -d' ' -f3

IT DOESN'T WORK, it print in some rows the username, in others the numer 1:
example:

username
username
username
1
1
1
username
1


If I remove the -a opzion IT WORKS:

permission=rw-r--r--
ls -lR | grep "^-$permission" | cut -d' ' -f3

IT print:
username
username
username
username

Why?
  #2 (permalink)  
Old 01-08-2008
sysgate's Avatar
sysgate sysgate is offline Forum Advisor  
Unix based
  
 

Join Date: Nov 2006
Location: Bulgaria
Posts: 1,322
I'm not sure why, but
Code:
ls -laR | awk '{print $3}'
will do the same. When it comes for printing columns, awk comes first in my mind
  #3 (permalink)  
Old 01-08-2008
DNAx86 DNAx86 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 69
thank you.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0