- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Scripting - conditional statments
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2006 05:34 AM
тАО03-22-2006 05:34 AM
Scripting - conditional statments
Our script has multiple if statments. Is there any way to find out for a particular if statment where is the closing "fi" statment in vi editor?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2006 05:42 AM
тАО03-22-2006 05:42 AM
Re: Scripting - conditional statments
You can install and compile the ehanced vi editor, designed for Linux. Or you can try and compile emacs.
I do it the old fashioned way. I indent every if and make sure the concluding fi is indented the same number of characters.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2006 05:45 AM
тАО03-22-2006 05:45 AM
Re: Scripting - conditional statments
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2006 06:31 AM
тАО03-22-2006 06:31 AM
Re: Scripting - conditional statments
Create a file called countem.awk
/ if / {addit++; print addit, $0;next;}
/^if / {addit++; print addit, $0;next;}
/ fi / {print addit,$0; addit--;next;}
/^fi / {print addit,$0; addit--;next;}
/^fi$/ {print addit,$0; addit--;next;}
/ fi$/ {print addit,$0; addit--;next;}
{print $0}
Then run: awk -f countem.awk < myfile | more
If you use elses, you may need to make some modifications. Basically you count up and then print the ifs and print then count down the fis.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2006 06:44 AM
тАО03-22-2006 06:44 AM
Re: Scripting - conditional statments
I like steve's suggestion to install emacs.
Steve - Once it is installed, how to do it? Is there any command like "%" in vi?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2006 07:11 AM
тАО03-22-2006 07:11 AM
Re: Scripting - conditional statments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2006 08:40 PM
тАО03-22-2006 08:40 PM
Re: Scripting - conditional statments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2006 08:47 PM
тАО03-22-2006 08:47 PM
Re: Scripting - conditional statments
parenthesis or brace at the current cursor position. Read man vi.
Hope vi is not supporting this. Use emacs.
--
Muthu