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.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Loop problem with one more problem aliahsan81 Shell Programming and Scripting 3 01-07-2009 02:02 AM
problem in finding a hardware problem girish.batra SUN Solaris 8 09-09-2008 10:10 AM
ssh script problem problem pcjandyala Shell Programming and Scripting 2 07-31-2008 03:27 PM
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 10:10 AM
SSH Problem auth problem budrito UNIX for Advanced & Expert Users 1 03-17-2004 10:12 AM

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

Join Date: Oct 2008
Posts: 11
cut problem

Hi,

sample datas are :

drwxr-xr-x 2 beewin abidev 96 Jun 13 2006 bwin
drwxrwxr-x 2 blsmg01 smg 96 Jun 13 2006 blsmg01
drwxr-xr-x 2 ccmdummy ccm_root 8192 Jun 13 2006 ccmdum
drwxr-xr-x 5 dipayan users 8192 Oct 29 09:05 dip

I want to cut the last field.

I use ls -ll | grep "dipayan" | cut -d" " -f22 to cut dip from
drwxr-xr-x 5 dipayan users 8192 Oct 29 09:05 dip.

but f22 is not working for other cases as the no of spaces are different for different data.
Is there any cut option so that always
ls -ll | grep "dipayan" | cut -d" " -f22 command cut the last field.
i.e. cut bwin for beewin and like that.
  #2 (permalink)  
Old 10-29-2008
KenJackson KenJackson is offline
Registered User
  
 

Join Date: May 2008
Location: Maryland, USA
Posts: 104
It looks like there are 9 fields, separated by spaces, not 22. Do you want to display only the last field?
Then use: cut -d" " -f9
  #3 (permalink)  
Old 10-29-2008
samir_standing samir_standing is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 11
Thanks for reply.
I already tried with that but it returns "users".
  #4 (permalink)  
Old 10-29-2008
samir_standing samir_standing is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 11
Problem with the data is, there are multiple spaces between fields and varys from data to data.
Is there any way to convert multiple spaces between fields to single space.
  #5 (permalink)  
Old 10-29-2008
KenJackson KenJackson is offline
Registered User
  
 

Join Date: May 2008
Location: Maryland, USA
Posts: 104
Quote:
Originally Posted by samir_standing View Post
Problem with the data is, there are multiple spaces between fields and varys from data to data.
Is there any way to convert multiple spaces between fields to single space.
Ah! Try this:
Code:
dir ... | sed 's/.* //'
That should delete everything up to and including the last space on the line.
  #6 (permalink)  
Old 10-29-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink try awk instead of a cut

in place of the cut, try awk

awk '{print $9}'

this will print the 9th field, which was separated by space and/or tab characters.
  #7 (permalink)  
Old 10-29-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
Or:

Code:
find . ! -name . -prune -user dipayan
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 12:00 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