![]() |
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 |
| need help in Parsing a CSV file and generate a new output file | vkr | Shell Programming and Scripting | 15 | 08-01-2008 07:33 AM |
| Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names | nikosey | Shell Programming and Scripting | 6 | 07-30-2008 09:46 PM |
| Parsing a file (sed/awk?) | aristegui | Shell Programming and Scripting | 10 | 06-25-2008 10:21 AM |
| Parsing xml file using Sed | kapilkinha | UNIX for Advanced & Expert Users | 3 | 04-08-2008 09:43 AM |
| Parsing a csv file | chiru_h | Shell Programming and Scripting | 6 | 02-12-2008 09:33 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Parsing a file
Hi guys,
what is the easiest way in ksh to parse a file? For example I want to find out a value of MIN_PASSWORD_LENGTH from /etc/default/security and I want to make sure it has a certain value. Of course I need to make sure the line is commented out, or if the are more lines with MIN_PASSWORD_LENGTH that at least one of them is commented out ... thanks, Kubko |
|
||||
|
Pardon my ignorance, but what kind of system are you using? How is the /etc/default/security file structured? Let's suppose it's just a whitespace-separated table, such as:
Code:
VALUE1 <data> VALUE2 <data> ... ... MIN_PASSWORD_LENGTH 8 ... ... VALUEn <data> Code:
grep ^MIN_PASSWORD_LENGTH /etc/default/security | awk '{ if ($2 > 6) print "Value is good"; else print "Danger, Will Robinson!" }'
|
|
||||
|
Quote:
Code:
... awk '{ if ...
Code:
... awk -F= '{ if ...
Code:
MIN_PASSWORD_LENGTH=7 #MIN_PASSWORD_LENGTH=2 #MIN_PASSWORD_LENGTH=3 #MIN_PASSWORD_LENGTH=6 |
|
||||
|
Quote:
![]() |
|
||||
|
sorry Andrew! :-)
What about if I have more references to MIN_PASSWORD_LENGTH in the file? like MIN_PASSWORD_LENGTH=4 MIN_PASSWORD_LENGTH=7 .. MIN_PASSWORD_LENGTH=x ? How could I handle this? Thanks again K. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|