The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
TO break a line aajan Shell Programming and Scripting 7 08-28-2007 04:12 AM
Insert line break in vi's command mode Skogsmulle UNIX for Dummies Questions & Answers 3 07-06-2007 10:47 AM
Replacing characters in file with line break johnemb Shell Programming and Scripting 10 04-26-2007 07:38 AM
Remove Line Break Rock Shell Programming and Scripting 5 02-06-2007 09:54 AM
Trim whitespace and add line break moose1 Shell Programming and Scripting 7 01-22-2007 01:53 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-16-2007
Janus Janus is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 18
Sed Help (Using expression - line break)

*Note, I thought I was in Shell Programming and Scripting Q&A and posted in a wrong forum. To avoid confusion and to inform people that I'm not trying to "spam" the forums, I'm adding this note up top*

Hi Everyone thanks in advance for any input you can provide on the following question! I'm currently working on AIX 5.3 and almost done with an audit script. I was given some more information from the admins today and I'm able to go back to a function that was semi-complete and expand it out some more. I'm working through the /etc/security/user file:

Within the script already I'm using a sed command to print out a file between 2 expressions:

cat /etc/security/user | awk '{print $1 $2 $3 ", "}' | sed -n '/default:/,/pwdchecks/p' | egrep 'histsize|loginretries|maxage|minlen|pwdwarntime'

This works well and fine for the user known as default, but if I need to run this on several different users (not just "default"), the second expression (the "pwdchecks") isn't always in the same spot for the given information. Here is an example in simpler terms:

The Setup:
Let's say I have information like so:

###BEGIN EXAMPLE INFORMATION###
AUser
AProperty1
AProperty2
AProperty3

BUser
BProperty2
BProperty3
BProperty1
###END EXAMPLE INFORMATION###

cat "filename" | awk '{print $1 $2 $3 ", "}' | sed -n '/user/,/property2/p'

Would give me AUser-AProperty2 but BUser-BProperty2 would only yield me those 2 lines, and not Property1 which I would need.

The Question:
What is the value I need to put where property2 is above and replace it so that the sed will go from "user" until it hits a "line break"?

By doing that, I'll always get the information for the User, it's properties and nothing will ever be missed? Does such a value for "line break" exist?
Thanks in advance for your input.
  #2 (permalink)  
Old 02-16-2007
Janus Janus is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 18
^$

I did a lot more research and found that if I used ^$, it'll print up and through the last line and blank line that follows thereafter

cat /etc/security/user | sed -n '/root:/,/^$/p'

My apologies again for the board spam, it wasn't meant to be that way...
  #3 (permalink)  
Old 02-16-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,209
Quote:
Originally Posted by Janus
My apologies again for the board spam, it wasn't meant to be that way...
Don't worry about that, you made clear in all of them what was intended; there were no posts in the accidental ones as a result, and I deleted them.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0