Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 12-01-2002, 03:53 PM   #1
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
LQ 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
Registered: Jun 2002
Location: Netherlands - Amsterdam
Distribution: RedHat 9
Posts: 549

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

Now i can finally move on.


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 > Forums > Non-*NIX Forums > Programming

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

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