The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
replace space with delimiter in whole file -perl meghana Shell Programming and Scripting 11 02-19-2008 06:35 PM
delete a field along with delimiter in the whole file dsravan Shell Programming and Scripting 5 11-01-2007 10:40 PM
remove space in front or end of each field happyv Shell Programming and Scripting 6 03-21-2007 11:05 PM
Set a variable field delimiter using awk Klashxx Shell Programming and Scripting 2 03-24-2006 06:10 AM
How to parse a text file with \034 as field and \035 as end of message delimiter? indianya Shell Programming and Scripting 1 08-26-2005 06:20 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-15-2003
Registered User
 

Join Date: Mar 2002
Posts: 1
Question field delimiter with a space or more

Is there some way to specify a field delimiter for a space or more (like " "+) ?
For example: In the following string, I like to reach value '30695' what field delimiter I should say? Thank you.
-rw-rw-r-- 2 uphamtn staff 30695 May 12 09:23 howToDo

----------------
I appreciate your response very much. Actually, my example string has one or MORE spaces but when it showed up on this page, it squezzes 2+ spaces into 1 space. In addition, I tried to use 'cut' command to get the size value of files from the output of 'ls -ltr' command.
Ex. ls -ltr | cut -d" " -f5 . This command will work if there is only one space separated between fields. And it won't work in my string because it has either one or more spaces between fields. Any idea ? Thanks.
======

IT WORKED, THANKS A LOT.

Last edited by uphamtn; 05-15-2003 at 01:35 PM.
Forum Sponsor
  #2  
Old 05-15-2003
google's Avatar
Moderator
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
I like to reach value '30695' what field delimiter I should say?
-rw-rw-r-- 2 uphamtn staff 30695 May 12 09:23 howToDo


get your list and pipe it to awk -

ll | awk -F" " '{print $5}'

will print a list at position 5. positions are delimited by a space ( -F" "). I think the default delimiter for awk is a space.
  #3  
Old 05-15-2003
oombera's Avatar
Registered User
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Could you explain more about what you're trying to do?

Here's one way to extract the value:
Code:
var="-rw-rw-r-- 2 uphamtn staff 30695 May 12 09:23 howToDo"
echo $var | awk '{ print $5 }'
Oops, I got beat out.
  #4  
Old 05-15-2003
oombera's Avatar
Registered User
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
The awk command will handle one space or 10 spaces, so the amount of space on your line shouldn't matter.. if you're gonna add the values up, see this post.

FYI, it screws up the continuity of the post when you start editing your previous posts after replies have been made.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




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


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0