Question about a basic shell script: How to make sure it receives only one input?
Hello all! I am very new to shell and Linux in general (I just started 2 days ago), I am trying to write a script that adds the size of the directories and files in a given directory and displays messages if the user puts in something wrong. I think I have covered all the possible problems except for one, I don't know how to make sure that the script checks that the user inputs only one directory and not more? If I try to run this program with 2 or more directories, then it runs the script for the first directory. How can I make the script to output a message saying that the user should specify only one directory to run the script on and not more?
If I did indeed grep something out of it, why woudln't $result show nothing?
When I do $? , it does show success...
What is the proper syntax so that $result shows actual thing it's grepping out?
result=`(ssh $host tail -1 /something/somethingelse) | egrep -i "value" >dev/null`
#echo... (3 Replies)
im trying to run the below if command
ifconfig -a |grep 10.100.120.21
gives me below output
inet addr:10.100.120.21 Bcast:10.100.120.255 Mask:255.255.255.0
i just want a basic shell which says if above exists then continue
how would i do this? (6 Replies)
I'm trying to approach a problem but all I'm coming up with are complex ways to manipulate the data. But still not getting the desired outcome.
directory of files....
file-100-foo
file-100-man
file-100-chu
Need to copy the files and increment the number in the file name
... (4 Replies)
Lets say I wanted to create a script that would show what people are doing on my machine using the w command and refresh in about 6 seconds. What would be the easiest way to do this? I pretty much want the script to loop until I stop it.
I'm using the BASH shell by the way.
Help is appreciated.... (1 Reply)
Im trying to make a script that simply adds a word to the last available line in a txt file without overwriting any previous lines.
Ive googled this and there are great examples but no one explain what each function does, and i dont entirely understand how it works.
Basically Im looking for... (7 Replies)
I have two shell scripts in the different directories listed below,
/root/dev/dir1/test.sh
/root/dev/dir2/master.sh
I am executing the master.sh script from the test.sh like below and getting 'Permission denied' error.
#! /bin/sh
#test.sh
path='/root/dev'
$path/dir2/master.sh
But it... (2 Replies)
Hi,
I have a shell script that creates 2 parallel processes. When I press ctrl+c, i want the parallel process to get killed as well.
#!/bin/bash
cmd1="script1.py"
cmd2="script2.py"
${cmd1} &
pid1=$!
echo ${pid1}
${cmd2} &
pid2=$! (7 Replies)
Hi,
Sorry if this is a newbie question. I guess you can use either awk or shell script for this sequence of operations, but knowing very little about either of them I'm not sure how I should try to write this.
The basic objective is to copy certain files that are scattered all over my... (10 Replies)
I need to have a script read a file that has a list of words in a single column like below:Black
Blue
Brown
Orange
Red
Yellow
Green
White
Purple
Silver
Grey
Tan
Then print to another file just all of the two-word possible combinations. Example:
Black,Blue
Anyone want to take a... (4 Replies)