Sponsored Content
Full Discussion: Writing Code
Homework and Emergencies Homework & Coursework Questions Writing Code Post 302377883 by akjim101 on Saturday 5th of December 2009 07:31:37 PM
Old 12-05-2009
https://fvsu.gabest.usg.edu/pls/B330...1&crn_in=24418

---------- Post updated at 06:47 PM ---------- Previous update was at 04:19 PM ----------

I have determined that I need to use

Code:
echo "$choice"

but the only problem is I dont know how to make grep run the echo code

---------- Post updated at 07:18 PM ---------- Previous update was at 06:47 PM ----------

update 2:

I figured out that I can complete this task by using this command:

Code:
 grep `echo "$choice"`

now the only thing I have left is to figure out how to make it scrollable... which I know i need to use

Code:
 more

but not sure exactly how to do that

---------- Post updated at 07:31 PM ---------- Previous update was at 07:18 PM ----------

Final Update:

was able to complete the project, here is my final code

Code:
clear
loop=y
while [ "$loop" = y ]
do
 tput cup 2 23; echo " ~*~*~*~*~*~*~*~*~*~*~*~*~ "
 tput cup 3 23; echo " * Search for a Pattern  * "
 tput cup 4 23; echo " ~*~*~*~*~*~*~*~*~*~*~*~*~ "
 tput cup 6 5; echo "Type in the pattern and path to the file you want to search for below," 
 tput cup 7 5; echo "or type Q to return to previous screen."
 tput cup 9 10; echo "Ex. : help /home/james/project/help"
 tput cup 11 5;
read choice || continue
 case $choice in
    [Q,q]) clear; exit ;;
    *) clear; tput cup 13 0; grep `echo "$choice"` | more; clear ;; esac
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Writing "find" code in C

I've got a project that writing "find" C code in solaris. That is finding a file in current and sub directories. While I am looking for some example on the book for two days, but I have no idea where to start. I think I need to use recursion, but is it true? I am still a Unix... (2 Replies)
Discussion started by: SQ4LIFE
2 Replies

2. Shell Programming and Scripting

conditional writing of sql code

Hello again... I have a request from another department to list for them all the columns and tables we use in this certain database. I have spooled the oracle stored procedured into 1 file. I need a way to write out parts of that file. The criteria is to to start the block to be written when... (0 Replies)
Discussion started by: kburrows
0 Replies

3. Shell Programming and Scripting

writing code!!!

suppose by writing this code "$ /sbin/ifconfig eth0| grep 'inet addr:' " i've got this output "inet addr:192.168.2.1 Mask:255.255.255.0" now if i want to see the output like this "IP address: 192.168.2.1 Subnet Mask: 255.255.255.0" what is the code should be? can anyone... (3 Replies)
Discussion started by: shelly
3 Replies

4. Programming

Writing c code for who | sort | lp

Hi, Can any one please let me know the code for implementing who | sort | lp Basically I want to implent pipe here. The program can use the existing who, sort and lp Also please let me know How many processes are created in Unix when the following commands are executed? $ ls... (17 Replies)
Discussion started by: yeheyaansari
17 Replies

5. Shell Programming and Scripting

Help in writing the code

hi i am studying unix with c language ,and completely new to this .I have question about how to pass the control from one program file to another.My first program has the main process and it should go into the second program where i can create six processes with also the usage of pipes to... (3 Replies)
Discussion started by: soumya_v7
3 Replies

6. Shell Programming and Scripting

script or piece of code where the data returned by a stored procedure you are writing

hi fndz. Can you please help me with the code if I call a stored procedure from my shell script and stored procedure returns a cursor, cursor output should be saved to a file (3 Replies)
Discussion started by: enigma_83
3 Replies

7. Programming

Vi question for writing source code

Hi guys, I'm modifying an old f77 code using vi. I'm modifying the code remotely from my windows machine using xming using vi. I'm using tabs to move past the first 6 columns of the code and to keep my loops and if statements neat, but when I hit the tab key, vi displays a big red block which is... (7 Replies)
Discussion started by: rks171
7 Replies

8. UNIX for Dummies Questions & Answers

sed remove two headers; writing more elegant code

Hi there, I have two questions. First, I was wondering how to use sed to remove two header lines or two tail lines. Here I just do the same operation twice...I'm sure there is a better way. Second, and more importantly, is there a better way to have these operations use files other than... (5 Replies)
Discussion started by: mikey11415
5 Replies

9. Shell Programming and Scripting

Writing a UNIX script from LOG to provide return code.

Folks - Firstly, I do apologize that my first post here is a question. I am quite familiar with UNIX since our application is running on it. We are trying to automate a few things on our end and I am challenged with a task in hand that requires UNIX scripting. I am totally a newbie in UNIX... (4 Replies)
Discussion started by: sk72
4 Replies

10. Shell Programming and Scripting

Help writing code

Hi, i need a string that take from a log file just two words (ngwan0) and his related ip address and then execute 2 commands in a shell. Any ideas where to start? Thanks (3 Replies)
Discussion started by: Board27
3 Replies
ZGREP(1)						    BSD General Commands Manual 						  ZGREP(1)

NAME
zgrep, zegrep, zfgrep -- print lines matching a pattern in gzip-compressed files SYNOPSIS
zgrep [grep-flags] [--] pattern [files ...] zegrep [grep-flags] [--] pattern [file ...] zfgrep [grep-flags] [--] pattern [file ...] DESCRIPTION
zgrep runs grep(1) on files or stdin, if no files argument is given, after decompressing them with zcat(1). The grep-flags and pattern arguments are passed on to grep(1). If an -e flag is found in the grep-flags, zgrep will not look for a pattern argument. zegrep calls egrep(1), while zfgrep calls fgrep(1). EXIT STATUS
In case of missing arguments or missing pattern, 1 will be returned, otherwise 0. SEE ALSO
egrep(1), fgrep(1), grep(1), gzip(1), zcat(1) AUTHORS
Thomas Klausner <wiz@NetBSD.org> BSD
December 28, 2003 BSD
All times are GMT -4. The time now is 08:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy