two simple question on shell scripts....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting two simple question on shell scripts....
# 1  
Old 10-10-2004
Computer two simple question on shell scripts....

Smilie my first question is how can envoke filename expansion from within a shell script.. forinstance if i execute the script and it asks for a specific directory that i would like to cd to, how can i get the script to use the same file name expension as the command line..
my second question is how can I run a new shell in the middle of an executed script for edditting files using the stream editor specifically..
# !/bin/sh
# .file_manager


function usage () { echo "USAGE"; echo "in $USER for text invoked by grep Directory must be prefixed by "Filesystem1" (ex.. Filesystem1/linuxconcpt/databseii); in root mode prefix with Filesystem1 all the time.. CWD (current working directory must be /hom
e/$USER/Filsystem1 in both .......)": echo "choose from named parameters ...,Nts,nts.. TXT, txt, Txt , loc or Loc, fle or Fle,fls or Fls"; echo "*capital for text, lowercase for directories and files"; echo "Exec & EXEC only uppercase..!"; echo "choose Mo
nth/month to get first 7 lines of text.. (Month ,only text, for Dir Unixformat)"; echo " Month can be applied to Dir linuxconcpt as all other text choices"; echo "enter C to access C_programms Dir"; echo "Enter dirctory or suffix or both..(must enter suf
fix.. enter all or ls to see addresses"; echo "enter X or x for xterm)"; echo "press CL/C to exit"; }

while :;do
usage
echo `pwd`
echo "Enter Dirctory or Hit Enter :"
read Dir
read input

if [ $DIR -d ]
then
echo "$Dir"
else
:;
while [ $input == 0 ]
do
dir="/home/moxxx68/Filesystem1"

done
fi

echo "Enter choice:"
read type
case $type in
Txt) grep -R -nB2 "(Txt)" ~/$Dir/* |less && ls -ali ~/$Dir --color
;;
Loc) grep -R -nB2 "(Loc)" ~/$Dir/* | less && ls -ali ~/$Dir --color
;;
Nts) grep -R -nB2 "(Nts)" ~/$Dir/* | less && ls -ali ~/$Dir --color
;;
Fle) grep -R -nB2 "(Fle)" ~/$Dir/* | less && ls -ali~/$Dir --color
;;
Fls) grep -R -nB2 "(Fls)" ~/$Dir/* | less && ls -ali ~/$Dir --color
;;
Exec) grep -R -nB2 "(Exec)" ~/$Dir/* | less && ls -ali ~/$Dir --color
;;
EXEC) grep -R -nB2 "(EXEC)" ~/$Dir/* | less && ls -ali ~/$Dir --color
;;
Month | month) egrep -R -n5 "(month\:|Month\Smilie" ~/$Dir/* | less && ls -$1 ~/$Dir --color | more
;;
txt) ls -$1 --color ~/$Dir | grep -n 'txt' | column -t
;;
loc) ls -$1 --color ~/$Dir | grep -n 'loc' | column -t
;;
nts) ls -$1 --color ~/$Dir | grep -n 'nts' | column -t
;;
fls) ls -$1 --color ~/$Dir | grep -n 'fls' | column -t
;;
fle) ls -$1 --color ~/$Dir | grep -n 'fle' | column -t
;;
doc) ls -$1 --color ~/$Dir | grep -n 'doc' | column -t
;;
c) ls -$1 --color ~/$Dir | grep -n 'c' | column -t
;;
TXT) egrep -nA5 -R '([a-z]|[0-9]\Smilie' ~/$Dir/* | less && ls -$1 ~/$Dir --color | more
;;
all) ls -$1 --color ~/$Dir | more && xterm -bg black -fg white ; egrep -R -nA5 '([a-z]|[0-9]\Smilie' ~/$Dir/* | less
;;
ls) ls -$1 ~/$Dir --color | more
;;
X|x) xterm -bg black -fg white&
;;
clear) { clear; pwd; tty; date; }
continue;
;;
exit) { clear; pwd; tty; date; }
break;
;;
*)echo "ERROR NO SUCH USAGE"
;;
esac;


done
any feedback welcome
thanx moxxx68Smilie

Last edited by moxxx68; 10-10-2004 at 04:45 PM..
# 2  
Old 10-15-2004
MySQL trying to make sense of these two questions..

Smilie i can just envoke the use of a shell for the stream edittor through a xterm terminal.. but what i really would like to know.. is it possible to script in a basic command as in C (fopen) where i go directly to a file on the through the script using forever loops to get in and out of the file on the same screen or would this be taskious. also i have never actually thought about it before but there must be some way to get directory and filename expansion as part of the response to the script prompt to enter dir path.. if any one could leave any kind of information I would be glad to figure out the rest by myself.....
would appreciate input from anyone
thanx moxxx68Smilie Smilie
# 3  
Old 10-15-2004
Re: trying to make sense of these two questions..

Quote:
Originally posted by moxxx68
Smilie i can just envoke the use of a shell for the stream edittor through a xterm terminal.. but what i really would like to know.. is it possible to script in a basic command as in C (fopen) where i go directly to a file through the script using forever loops to get in and out of the file on the same screen or would this be taskious. also i have never actually thought about it before but there must be some way to get directory and filename expansion as part of the response to the script prompt to enter dir path.. if any one could leave any kind of information I would be glad to figure out the rest by myself.....
would appreciate input from anyone
thanx moxxx68Smilie Smilie
# 4  
Old 10-15-2004
Re: Re: trying to make sense of these two questions..

Quote:
Originally posted by moxxx68
oops accident,,,, no reply required !
Quote:
the rules no bumping
unitentional editting mistake,,,,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Syslog.conf: looking for a simple answer on a simple question

Cheers! In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not? To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
Discussion started by: dr1zzt3r
6 Replies

2. Shell Programming and Scripting

General question about passing variables among shell scripts

So this is something I've been wondering how to do for a while. Suppose I have two shell scripts a.sh and b.sh script a does some function and outputs to a varable $x . I would then like to take $x into the second function, b.sh, and do a function on it and create some output. So how do you pass... (3 Replies)
Discussion started by: viored
3 Replies

3. Shell Programming and Scripting

Asynchronous shell scripts question - newbie

Hi All, I am fairly new to UNIX and very new to this forum too. This is my first post here. Here is my scenario - I have 3 scripts script1, script2 and script3. I want to start script1 and script2 asynchronously. Upon completion of both scripts script1 and script2, i want to fire the last... (4 Replies)
Discussion started by: taskeen21
4 Replies

4. Shell Programming and Scripting

Newbie question-do I pause and exec my shell scripts?

Hi there, I'm writing a script to restore 3 directories and 3 mysql db's every 24 hours. While writing the script, I came across the thought... Do I need to pause between executions? Example: msql restore1.sql rm -Rf path1/* cp -Rf path1/* /restore1 chmod 777 /folder1/cache1 ... (2 Replies)
Discussion started by: semiotics101
2 Replies

5. Shell Programming and Scripting

Simple Shell Script Question.... [java related]

Hey guys! This is my first post, as im new here :S I have a simple problem for a big program. We have a .sh to install it, but when I run the .sh in terminal like i should, It says the class is not found. I believe it has to do with the syntax, as the person who made it is not a linux pro. I... (3 Replies)
Discussion started by: Drags111
3 Replies

6. Shell Programming and Scripting

Need a simple file based utilty for shell scripts

Hello, I'm wondering if you may know of a simple file based UNIX utility that can be used to store and retrieve values on a flat file, let's say i have a file called "kru", i'd like to be able to specify a request like: while(....) if ; then kru.fld2 = $rec_cnt kru.fld3 =... (4 Replies)
Discussion started by: bobk544
4 Replies

7. Shell Programming and Scripting

shell scripts question

Hi I am trying to do the following use a shell script to draw from various online table to the table on my server. it draws from one online table which has a set of columns one of which is in the form say 2006ab i want to use this as input to copy into another column an http link that has... (0 Replies)
Discussion started by: wannabegeek
0 Replies

8. UNIX for Dummies Questions & Answers

Ok simple question for simple knowledge...

Ok what is BSD exactly? I know its a type of open source but what is it exactly? (1 Reply)
Discussion started by: Corrail
1 Replies

9. Shell Programming and Scripting

simple shell scripts

hi everyone... i'm new to this shell programming and i want help with the following question... i hope someone can help me ...pls plsssssssssss ========================================================== the question ========================================================== A number of... (1 Reply)
Discussion started by: moon14
1 Replies

10. Shell Programming and Scripting

A simple shell question

Hi all... here is my question: in the following, will the `cd $ref_ntp` work? for i in `cat $fic` do { echo " " echo ================$i============================= OS=`$CMD -s $i "uname"` case $OS in SunOS) ref_ntp=/ref/ntp/SUN ;; HP-UX) ref_ntp=/ref/ntp/HP ;; esac ... (2 Replies)
Discussion started by: a_new_admin
2 Replies
Login or Register to Ask a Question