Having issues finishing up a few scripting problems. A little help would be awesome
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
4. Recall that the env command provides a list of various environment variables available to you. Two of those variables are PWD, which is your current directory, and HOME, which is your home directory. Write a script named script7.sh to test to see if you are currently in your home directory. This will be true if $PWD is equal to $HOME. Output the result.
5. The following piece of code will loop through and print the files located in the current directory.
The condition [ -r $filename ] tests to see if $filename is readable. Write a script named script8.sh that uses a for loop to iterate through the current directory and test to see which files are readable. Output the names of all the readable files found in the directory. Include your script script8.sh as your answer to this problem.
6. You can use the same logic that you used above by using the command cat $filename to output all of $filename.
Write a script named script9.sh where, in place of $filename, you pass in a parameter of a text file’s name. This will be referenced as $1 in the script. Pass in a second parameter, a string, which will be referenced as $2. Using the for loop with cat, count the number of occurrences of the string ($2) in the file. Output the string ($2) and the number of times you found it in the file. Test this out on a few different text files to make sure it works. Include your script script9.sh as your answer to this problem.
2. Relevant commands, code, scripts, algorithms:
5. gives a hint as to what I need to be looking at with:
6. gives a hint as to what I need to be looking at as well
3. The attempts at a solution (include all code and scripts):
I'm having issues even attempting a solution. I would appreciate even advanced help on these, or give examples like what it should be showing.
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Northern Kentucky University, KY, USA, Prof. Walker, CIT-130
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
Last edited by Scrutinizer; 10-05-2014 at 04:40 PM..
Reason: code tags
Hello,
Im trying to write a script where it will only execute on a certain day. What would the script look like?
if
then do this
is this correct?? (13 Replies)
hi,
I am stuck in a shell script where in i need to extract the specific users from \etc\passwd file. Once this is done, i need to assign Roles to these users which are different for different users. What could be the optimum solution. If i hard code the Roles values in a text file, how would i... (1 Reply)
Hi guys,
I am thanks in advance for any posts and for reading. I am trying to run this script, under solaris:
echo "****************************************"
echo "The host is: "
echo "****************************************"
<<EOF find /etc/default -name login -exec ls -l {} \;
find... (5 Replies)
the first one:
1.
i am trying to build a command that searches a text file
and outputs the number of words which consists of two 'b' characters
in each word separatly
like
barby
(the b characters must be separated from one another)
i tried to use grep filepath
then i know that we need... (3 Replies)
Hi,
In my unix server, i received a file in /usr/data/xmit location. i want to write a unix script after file reached.
So how can i write a one line code which chceks the presence of the file? and second line line should take the status of the prevous line. like below.
Line 1: checks for the... (16 Replies)
Hello everyone, I am new to the forum community and need help with some scripts. I have attached what I have so far and these are scripts that have been passed on to me for a project that I have been assigned. To tell the truth I have never really worked with scripts and have no clue how these even... (3 Replies)
Hello everyone, I am new to the forum community and need help with some scripts. First off let me put that this is “NOT” a homework assignment as I have been given this information where I work (IUPUI-UITS) and need help on this since I have no experience in this area. The only reason I am turning... (1 Reply)
Below is the data file(results) contents-
13450708,13470474,US,15
24954,24845,JPN,44
14258992,14365059,US,4
24954,24845,IND,44
I want to send above data sets to email in a tabular format. For that I am using below awk script. Now the challenge I am facing here is - I want to make the... (2 Replies)