modify ls -l (long listing format output) strictly using SED only straightforward goalhard 4 me doh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting modify ls -l (long listing format output) strictly using SED only straightforward goalhard 4 me doh
# 1  
Old 06-12-2012
Data modify ls -l (long listing format output) strictly using SED only straightforward goalhard 4 me doh

Below is a sample out of ls -l which I would like to rearrange or modify by field numbers for example I successfully managed to disect using simple paragraph however for ls -l I can't divide the rows or fields by field number.

Successful modification by fields using SED sample:
Code:
[localuser@localhost ~]$ sed -e 's/^\(.*\) \(.*\) \(.*\) \(.*\) \(.*\)/1stString (\1) 2ndWord (\2) 3rdWord (\3) 4thWord (\4) 5thWord (\5)/' maryhad
1stString (Mary) 2ndWord (had) 3rdWord (a) 4thWord (little) 5thWord (lamb.)
And everywhere that Mary
1stString (went, the lamb) 2ndWord (was) 3rdWord (sure) 4thWord (to) 5thWord (go.)
Mary was not Mary'd

#Beta Script not functioning like the one above: not dividing the strings as I intended:Smilie
Code:
[localuser@localhost ~]$ head -3 tabc.txt | sed -e 's/^\(.*\) \(.*\) \(.*\) \(.*\) \(.*\)/1stString (\1) 2ndWord (\2) 3rdWord (\3) 4thWord (\4) 5thWord (\5)/'
)stString (-rwx------- 1 alice   staff     1586) 2ndWord () 3rdWord (2010-11-05) 4thWord (02:27) 5thWord (request-key.conf
)stString (-rwx------- 1 ted   staff     126) 2ndWord () 3rdWord (2011-04-29) 4thWord (13:54) 5thWord (cvs-pserver.conf
)stString (-rwx------- 1 carol   staff     644) 2ndWord () 3rdWord (2011-03-06) 4thWord (21:58) 5thWord (ts.conf

straightforward goal/intent:

separate long listing format fields output of ls using SED only please.

Thank you and welcome for suggestions
# 2  
Old 06-12-2012
Try this:

Code:
sed -e 's/^\([^ ]*\)  *\([^ ]*\)  *\([^ ]*\)  *\([^ ]*\)  *\([^ ]*\)/1stString (\1) 2ndWord (\2) 3rdWord (\3) 4thWord (\4) 5thWord (\5)/'

For files with spaces in their name consider -Q (quote name) option of ls.
This User Gave Thanks to Chubler_XL For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to generate HTML output format listing like orasnap

Hi, Is there any UNIX scripts out there that generates a listing output of some sort similar to OraSnap At the moment, I have a script that I run on multiple servers that has multiple databases and just querying the database sizes of those databases. It generates a text files that contains... (0 Replies)
Discussion started by: newbie_01
0 Replies

2. Solaris

Grant unprivileged user rights to see the output of echo|format but not modify disks

anyone have any idea how do to this with auth_attr? I suspect if I grant him solaris.device.:RO::Device Allocation::help=DevAllocHeader.html that will work but I'm unsure. Just looking for a second opinion. (10 Replies)
Discussion started by: os2mac
10 Replies

3. Shell Programming and Scripting

Format output sed

For each token in this file: Al+nHr Al+ErAqy syAsy lA TA}fy Al+ArbEA' $wAl I hope to get this: AlnHr Al+nHr AlErAqy Al+ErAqy syAsy syAsy lA lA TA}fy TA}fy AlArbEA' Al+ArbEA' $wAl $wAl So I want have this format in each line: <token with no +><space><original token> Is... (1 Reply)
Discussion started by: Viernes
1 Replies

4. Shell Programming and Scripting

Modify a perl line to parse out and output to another format

Hey there... I am looking for a way to take the below contents ( small excerpt) of this file called PTR.csv ptrrecord,0000002e0cc0.homeoffice.anfcorp.com,,10.11.191.62,,,False,62.191.11.10.in-addr.arpa,,302400,default... (6 Replies)
Discussion started by: richsark
6 Replies

5. UNIX for Dummies Questions & Answers

shell script for long listing of groupnames

Hello, When listing the file systems (using ls -ltr) , if the group names are longer the group name is getting truncated. Can someone help with the script which would display the truncated group name? I appreciate if someone could help in this regard. (3 Replies)
Discussion started by: mike12
3 Replies

6. Solaris

Listing the long groupnames

Hello, When listing the file systems (using ls -ltr) , if the group names are longer the group name is getting truncated. Can someone help with the script which would display the truncated group name? I appreciate if someone could help in this regard. (1 Reply)
Discussion started by: mike12
1 Replies

7. Shell Programming and Scripting

sed and Output line too long

hello i try this command in console mode sed -e :a -e '/$/N; s/\(\)\n/\1 /; ta' test.txt > result.txt i have in the output screen "Output line too long" for multiples lines can you please tell me how can i retrieve those long lines during the execution ? Another thing very... (5 Replies)
Discussion started by: ade05fr
5 Replies

8. Shell Programming and Scripting

grep/matching help with long listing of directories

How do I get this to work? cat somefile | grep "-rw-r--r-- 1 root wheel 287 Sep 10 15:12 shells~" This is the the desired output -rw-r--r-- 1 root wheel 287 Sep 10 15:12 shells~ I basically want an exact match of the line I am grepping for, the special characters and... (5 Replies)
Discussion started by: streetfighter2
5 Replies

9. Shell Programming and Scripting

ls -l output with long iso format

Hello everbody, I've a list of logfiles (transfer1.log, transfer2.log, ... transfer168.log.) Each of these was created at the end of the actual month and I've to write a script to calculate the utilisation ratio of the actual month of the system. I don't want to scan every logfile, so I've to... (1 Reply)
Discussion started by: rofflox
1 Replies

10. UNIX for Dummies Questions & Answers

long listing of files up to a given date

Hi I would like to a long list of files up to a given date. I've tried: ls -al > filelist but this command gives me all the files. I've also have tried the find command: find . -mtime -10 -type f -print > filelist This gives me information on active file within the past 10 days and... (2 Replies)
Discussion started by: rlh
2 Replies
Login or Register to Ask a Question