LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 03-23-2005, 06:12 AM   #1
cookie_ie
LQ Newbie
 
Registered: Mar 2005
Posts: 13

Rep: Reputation: 0
bash script problem


I need help, I am only new to shell but an advanced programmer in other languages, I have to write this all in script though.

Problem 1. I need to modify the output from ls -l to be more "user friendly", I would like to replace the r,w,x with read,write,exe. Was thinking I could write it to a temporary file, go through that and replace the approaite ones, then output them back to the screen.

Is there a way of using sed to catch a string?

Problem 2. I need to control the output from dmesg to only output the first ten lines.

Any help with these problems would be really great.
 
Old 03-23-2005, 07:55 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
For the 1. I am not sure if your output will be more user friendly as the ls lines will be very long like :

ls -l ~
read write execute|read- execute|read - execute Desktop/
read-write-execute|read- -|read- - file
...
On a 80 columns terminal, this sort of output does not render well

for the 2:
dmesg | head -10

Last edited by keefaz; 03-23-2005 at 07:57 AM.
 
Old 03-23-2005, 12:30 PM   #3
cookie_ie
LQ Newbie
 
Registered: Mar 2005
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks for part 2

Thanks for that part 2, really does the job for what I need. Basically my brief for the ls -l command is to make it more user friendly, have you any ideas on ways to achieve this. I thought if you could but like a table head above the ls -l command that might help

r = read
w = write
x = execute
- = no access
|USR|GRP|OTR| |File Name|
drwx rwx -wx joebloggs

that was my idea, do you feel this would be user friendly enough?
 
Old 03-23-2005, 02:19 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Code:
for the 2:
dmesg | head -10
-10 is redundant here, as head by default is displaying the first 10 lines anyway.
Code:
dmesg | head
is enough.
 
  


Reply



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
bash script problem fatbastard spice Linux - General 2 08-24-2005 02:15 AM
bash script problem GATTACA Programming 3 06-13-2005 09:59 AM
Problem with this bash script cantabile Programming 3 06-06-2005 05:31 PM
bash script problem sorry99 Programming 2 09-20-2004 09:02 AM
Bash script problem kalleanka Programming 2 01-30-2004 11:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration