![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. |
|
||||
|
^$
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... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|