LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-11-2011, 06:43 AM   #1
geep1980
LQ Newbie
 
Registered: Jan 2011
Posts: 10

Rep: Reputation: 0
Align Menu script


I am creating a script that creates a Menu to go true.

I have done the following

Code:
seq -s ""#"" 70 | sed 's/[0-9]//g'
echo " "  | sed -e :a -e 's/^.\{1,65\}$/ & /;ta'  | sed 's/^/#/' | sed 's/$/#/'
echo "U heeft 1 van onderstaande mogelijkheden" | sed -e :a -e 's/^.\{1,65\}$/ & /;ta' | sed 's/^/#/' | sed 's/$/#/'
seq -s "-" 68 | sed 's/[0-9]//g' | sed 's/^/#/' | sed 's/$/#/'
echo " "  | sed -e :a -e 's/^.\{1,65\}$/ & /;ta' | sed 's/^/#/' | sed 's/$/#/'
echo -e "[1] Stoppen van de processen op \033[31malle servers \033[37m" | sed 's/^/#    /'| sed 's/$/#/'
echo -e "[2] Stoppen van de processen op enkele server" | sed 's/^/#    /' | sed 's/$/#/'
echo -e "[3] Starten van de processen op \033[31m alle servers \033[37m" | sed 's/^/#    /' | sed 's/$/#/'
echo "[4] Starten van de processen op 1 enkele server"  | sed 's/^/#    /' | sed 's/$/#/'
echo "[5] Een ander beheer script starten" | sed 's/^/#    /' | sed 's/$/#/'
echo -e "\033[33m \033[41m[A] Aanpassen file met alle servers \033[40m \033[37m" | sed 's/^/#   /' | sed 's/$/#/'
echo "[Q] Stop / Exit " | sed 's/^/#    /' | sed 's/$/#/'
echo  " "  | sed -e :a -e 's/^.\{1,65\}$/ & /;ta' | sed 's/^/#/' | sed 's/$/#/'
seq -s ""#"" 70 | sed 's/[0-9]//g'
echo -n "Maak uw keuze: "
The problem I have is that I want each line to start with the first 5 positions being "# " and al lines must end with a "#" at the same position (for example 78)

Can someone help me with my problem
 
Old 11-11-2011, 08:53 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
Personally I wouldn't give a rats ass for eye-pleasing menus and simply use whatever BASH "select" prints to get the job done (unless your job is to look at preeeetty, preeeeeetty menus, that is ;-p). If you don't want use a CLI tool like 'dialog' (ncurses) then you'll probably want to use 'tput' as in http://wiki.bash-hackers.org/scripting/terminalcodes / http://tldp.org/LDP/abs/html/colorizing.html.
 
Old 11-11-2011, 03:36 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,837

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
1) Please specify the shell language you're using.

2) Effective use of whitespace, indenting, and comments help to make a script readable and more easily debuggable. Huge, unbroken blocks of commands are hard to decipher.

3) Try storing the raw text in variables, rather than echoing the strings directly. Then you can use the shell's built-in string manipulation features to handle some of the text work.

4) Assuming bash or another shell that supports it, you can also probably use the printf command to control formatting, rather than external tools like sed.

5) Heck, why try to dynamically format it at all? Why not just build a static, or at least mostly static, menu? The less you can rely on external tools, the more efficient the script will be. You can store the pre-formatted menu in a here document, and put it in a function to print it on demand. Another option could be to store it in an array with one line per element.

6) You might consider using dialog instead. Why reinvent the wheel when there are already tools designed to do this for you?
 
Old 11-17-2011, 02:20 PM   #4
geep1980
LQ Newbie
 
Registered: Jan 2011
Posts: 10

Original Poster
Rep: Reputation: 0
It was a strugle and had help from your tips.

I have solved my problem.

Thank you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Send input from one script to another menu based script. simonedgcumbe Programming 9 03-24-2010 10:22 PM
vim align c file saurin Linux - Newbie 4 01-03-2010 04:42 PM
Align lines in shell script jeesun Linux - General 5 10-16-2009 01:29 AM
Align LaTeX correctly edgjerp Linux - Software 2 10-23-2007 09:03 AM
align cartridges nielchiano Linux - Hardware 3 02-03-2004 05:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration