Sponsored Content
Top Forums Shell Programming and Scripting modify ls -l (long listing format output) strictly using SED only straightforward goalhard 4 me doh Post 302655109 by wolf@=NK on Tuesday 12th of June 2012 08:47:54 PM
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
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
ARITHMETIC(6)							 BSD Games Manual						     ARITHMETIC(6)

NAME
arithmetic -- quiz on simple arithmetic SYNOPSIS
arithmetic [-o +-x/] [-r range] DESCRIPTION
arithmetic asks you to solve problems in simple arithmetic. Each question must be answered correctly before going on to the next. After every 20 problems, it prints the score so far and the time taken. You can quit at any time by typing the interrupt or end-of-file character. The options are as follows: -o By default, arithmetic asks questions on addition of numbers from 0 to 10, and corresponding subtraction. By supplying one or more of the characters +-x/, you can ask for problems in addition, subtraction, multiplication, and division, respectively. If you give one of these characters more than once, that kind of problem will be asked correspondingly more often. -r If a range is supplied, arithmetic selects the numbers in its problems in the following way. For addition and multiplication, the numbers to be added or multiplied are between 0 and range, inclusive. For subtraction and division, both the required result and the number to divide by or subtract will be between 0 and range. (Of course, arithmetic will not ask you to divide by 0.) The default range is 10. When you get a problem wrong, arithmetic will remember the numbers involved, and will tend to select those numbers more often than others, in problems of the same sort. Eventually it will forgive and forget. arithmetic cannot be persuaded to tell you the right answer. You must work it out for yourself. DIAGNOSTICS
``What?'' if you get a question wrong. ``Right!'' if you get it right. ``Please type a number.'' if arithmetic doesn't understand what you typed. SEE ALSO
bc(1), dc(1) BSD
May 31, 1993 BSD
All times are GMT -4. The time now is 12:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy