LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-01-2002, 03:53 PM   #1
pk21
Member
 
Registered: Jun 2002
Location: Netherlands - Amsterdam
Distribution: RedHat 9
Posts: 549

Rep: Reputation: 30
Simple bash question


Can anyone tell me how i can get the string -rw-r--r-- to be seperated in -, rw-, r-- and r--?

I think i have to use sed but am not sure

Help would be appreciated.
 
Old 12-01-2002, 05:00 PM   #2
mhearn
Guru
 
Registered: Nov 2002
Location: Durham, England
Distribution: Fedora Core 4
Posts: 1,565

Rep: Reputation: 47
results=( `echo "-rw-r--r--" | sed 's/\(.\)\(...\)\(...\)\(...\)/\1 \2 \3 \4/'` )
echo ${results[2]}

--> "rw-"

alter 2 to any number between 0 and 3 to get the component parts.

hope that helps -mike
 
Old 12-01-2002, 05:06 PM   #3
pk21
Member
 
Registered: Jun 2002
Location: Netherlands - Amsterdam
Distribution: RedHat 9
Posts: 549

Original Poster
Rep: Reputation: 30
Great, thanks!!!!

Now i can finally move on.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very simple BASH scripting question clickster Linux - Newbie 6 11-23-2005 04:28 PM
very simple bash programming question!? Thinking Programming 7 06-01-2005 11:07 AM
Simple Bash Question sio Programming 6 11-22-2004 09:56 AM
simple bash script question bullium Programming 3 11-01-2004 02:42 PM
Bash Scripting--Simple Question mooreted Linux - General 4 05-10-2004 01:44 PM


All times are GMT -5. The time now is 03:14 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration