04-13-2006
New Person Added to the Forum
Hello,
I'm brand new to this forum. I am working on my first Bash shell script. We were given an exercise to get ready for the real assignment. I could use some help.
The exercise is to "set two variables (i. e., file1 & file2) on the command line to the paths of the text files. We are to create a shell script that does the following:
"if either variable does not have a value, output a message and stop. file1=${file1:?must set file1} & file2=:?must set file2} is what I've composed so far.
The output : "There are ___________ lines total in the files. ________has __________% (files) as many __________. "
#I did this part. I typed in lines of text into both files. We are to use quota, echo, run tests, and edit/compose the script in the Vi editor.
The process of doing this is a bit confusing to me.
First I set variables.
Second, I create paths w/text.
Third, I export files.
Fourth, run tests.
Fifth name script files in Vi.
What does $SHELL do?
Can someone model this entire process for me so that I can get a handle how to accomplish the basics of using vi and writing a script?
I would be greatful!
Sincerely,
William Carpenter
5 More Discussions You Might Find Interesting
1. Solaris
Ok i have a router, which my sparc 5 is connected to. I can acess the router webpage (192.168.0.1). But I cant access the internet.
When i use sys-unconfig i enter my ip address fine then i click none for when it asks me for DNS info because I dont have a domain. I was told i can manually change... (10 Replies)
Discussion started by: vikster007
10 Replies
2. Shell Programming and Scripting
I have given file with three columns,example:
mm234 5 22
mn237 6 45
de987 4 41
I have to check for input values in second and third column and if it is not numeric I have to deleted using grep function. I keep trying. But help from pros might help me.
We know that there is only one... (4 Replies)
Discussion started by: ljubayuu
4 Replies
3. What is on Your Mind?
Simple rules...
1. Guess who it is, the first person to get it posts the next picture, post your guess as a reply to this thread.
2. Wait for the person who posted the picture to confirm that you are correct before posting a new picture.
3. If the person who posted the picture does not answer... (268 Replies)
Discussion started by: reborg
268 Replies
4. Shell Programming and Scripting
Hi
My question:
Is there a way to lock a script if its already running for other users?
Like if i want to start a script, that is running by another user, there will be a message: Hey, you cant start the script because its running by another user, try it later.
my idea was that the... (10 Replies)
Discussion started by: DarkSwiss
10 Replies
5. What is on Your Mind?
Today I changed the forum mysql database to permit 2 letter searches:
ft_min_word_len=2
I rebuilt the mysql search indexes as well.
Then, I added a "quick search bar" at the top of each page.
I have tested this and two letter searches are working; but it's not perfect,... (1 Reply)
Discussion started by: Neo
1 Replies
DIFF(1) General Commands Manual DIFF(1)
NAME
diff - differential file comparator
SYNOPSIS
diff [ -efbwr ] file1 ... file2
DESCRIPTION
Diff tells what lines must be changed in two files to bring them into agreement. If one file is a directory, then a file in that directory
with basename the same as that of the other file is used. If both files are directories, similarly named files in the two directories are
compared by the method of diff for text files and cmp(1) otherwise. If more than two file names are given, then each argument is compared
to the last argument as above. The -r option causes diff to process similarly named subdirectories recursively. The normal output con-
tains lines of these forms:
n1 a n3,n4
n1,n2 d n3
n1,n2 c n3,n4
These lines resemble ed commands to convert file1 into file2. The numbers after the letters pertain to file2. In fact, by exchanging `a'
for `d' and reading backward one may ascertain equally how to convert file2 into file1. As in ed, identical pairs where n1 = n2 or n3 = n4
are abbreviated as a single number.
Following each of these lines come all the lines that are affected in the first file flagged by `<', then all the lines that are affected
in the second file flagged by `>'.
The -b option causes trailing blanks (spaces and tabs) to be ignored and other strings of blanks to compare equal. The -w option causes
all white-space to be removed from input lines before applying the difference algorithm.
The -e option produces a script of a, c and d commands for the editor ed, which will recreate file2 from file1. The -f option produces a
similar script, not useful with ed, in the opposite order. It may, however, be useful as input to a stream-oriented post-processor.
Except in rare circumstances, diff finds a smallest sufficient set of file differences.
FILES
/tmp/diff[12]
SOURCE
/sys/src/cmd/diff
SEE ALSO
cmp(1), ed(1)
DIAGNOSTICS
Exit status is the empty string for no differences, for some, and for trouble.
BUGS
Editing scripts produced under the -e or -f option are naive about creating lines consisting of a single `.'.
When running diff on directories, the notion of what is a text file is open to debate.
DIFF(1)