I am wanting to create a menu that will list all the log files in a specific directory such as /apps/logs.
So it would be something like this:
#!/bin/ksh
print 'Select The Required Log File'
PS3='log? '
select choice in <this is to contain a list of files that are in a directory that would be populated using find /apps/logs>
If it means that a user should be presented with a menu that lists all log file from /apps/logs and then he wants to view 'em selectively then I think we could:-
1) find /apps/logs -type f
2) Number the files from find's output and present the user
3) At the time they are displayed populate them in an array
4) display user to enter choice and pull that choice from array.
So it would be something like this in ksh ( I havenot tried it..chk for syntax errors)
------------------------------------------------------
#!/bin/ksh
logcnt=0;
for logfile in `find /apps/logs -type f `
do
logarr[$logcnt]=$logfile
echo "$logcnt : $logfile"
((logcnt=$logcnt+1))
done
echo "Enter ur choice to view :\c"
read choice
cat "`cat ${logarr[$choice]}`"
-------------------------------------------------------------------
I havenot provided any kind of locking facility here to handle errors. It 's just an idea
Ygor,
Thanks for the info. It is almost what I am looking for.
I am needing a menu with some dynamic items from find and other static items.
$DYNAMIC_ITEMS is where i will use my find, etc. For now i just set it.
The $DYNAMIC_ITEMS will be run in a similar fashion but the others will need to be run differently.
I was trying to use select choice and case and for loop.
1. This is with you code and the menu works.
Which produces :
The problem is that ALL items are run the same way, in this case $ECHO $CHOICE.
Here is my manual method:
Everything with exception of Configuration, ALL, MENU,and Quit should be dynamically created.
I also can't get your code to work inside of a case statement. Any help would be appriciated!
I installed CentOS 8 with Gnome 3.28.2 and I noticed that the "switch user" menu item disappeared from under the system menu of Gnome classic (Both X11 & Wayland). I checked google and this problem seems to have a history going back several releases of Gnome.
Unfortunately, I never found a... (1 Reply)
Hey, im fairly new to unix and Im trying to make this unix project that would display a menu and do the following.
MENU
===========================
(p, P) Print users info
(a, A) Add new user
(s, S) Search user
(d, D) Delete user
(x,X) Exit
Enter your choice:
Trying to... (3 Replies)
Hi Master of masters,
Thanks for ur reply.
Need ur help for following. Is it possible to create menu for following in linux or a function.
> Look in logs > Status > Action > End Action
> CONFSUCCESS > Success > Show message as successful > Enter to continue
> CONFFAIL > Failure > Show... (1 Reply)
hi all i am a newbie to this
is there any examples on creating a main menu with 3 sub menu
main menu -> option a , b and c
a menu -> option 1 ,2 and 3
b menu -> option 1 ,2
c menu -> option 1 ,2
i am getting headache as my code kept getting unexpected EOF
---------- Post... (0 Replies)
Problem:
I am trying to create a menu in a menu script and I am running into an issue with the calculator portion of the script. I am first presented with the ==Options Menu== which all 5 options working correctly. Now comes the fun part. I select option 1 which takes me to my ==Calculator... (1 Reply)
Hi,
I need to go through all the files on my system and build a list/output file with the paths of all files where the first two characters within the file match an expression.
I know I can use something like
find . | xargs cut -b1-2
or
find . -exec cut -b1-2 {} \;
to get the characters... (3 Replies)
Hi,
I need your help co create a very small menu somthing that look like this:
1. first step
2. second step
3. last step
from step : ___
to step : ___
If the user choose 1 --> it will echo : Hellow
If the user choose 2 --> it will echo : World
If the user choose 3 --> it will echo... (4 Replies)
I am very new to Unix and know the basic commands. I have to write a script file and I'm completely lost. The script file is to show the following at the beginning:
Menu of Options
1. Display all files in a user's home directory.
2. Welcome yourself to the program.
3. Display System... (8 Replies)
Hi folks,
I have the following function ,which generates menu for installation type:
select_install_type()
{
echo
echo ========================================
echo Please select the type of installation:
echo ========================================
... (8 Replies)
Trying to alias rm to move files to a hidden trash directory in the bash shell. I've tried to create this alias numberous ways and it's just not working. Here's what I've tried, anyone have any suggestions.
alias rm='mv $* ~/.trash'
alias rm= 'mv$* ~/.trash'
things like that... I've also... (2 Replies)