Tagged Questions
0
votes
2answers
21 views
Attempting to pass two arguments to a called script for a pattern search
I'm having trouble getting a script to do what I want.
I have a script that will search a file for a pattern and print the line numbers and instances of that pattern.
I want to know how to make it ...
0
votes
2answers
26 views
Why doesn't this bit of code work? Setting variables and config file
I have recently just made this script:
if test -s ~/.rm.cfg ; then
rbin=$(grep / ~/.rm.cfg)
echo $rbin
else
rbin=$HOME/deleted
echo $rbin
fi
if test -d $rbin ; then
echo "Recycling ...
3
votes
4answers
26 views
Trying to create a file to call another file for a looped search
I'm attempting to write a script that calls another script and uses it either once, or in a loop, depending on the inputs.
I wrote a script that simply searches a file for a pattern and then prints ...
0
votes
1answer
29 views
Using the grep and cut delimiter command (in bash shell scripting UNIX) - and kind of “reversing” it?
So I have a file with the text:
puddle2_1557936:/home/rogers.williams/folderz/puddle2
I want to use the grep command
grep puddle2_1557936
Mixed in with the cut command (or another command if ...
1
vote
5answers
53 views
Shell script to truncate branch information and directories
Need cut/awk script to truncate the "/branches/testbranch/" and get directories path for the files but ignore the directories
/branches/testbranch/abc/efg/hij/klm/casestudy
...
-1
votes
1answer
26 views
Report with details like count of each consumer in each document in each hour
Thank you all for taking out your time and giving suggestions. Now I have reached where I need to get report which would count of each consumer of each document in each hour.
I have come up with this ...
0
votes
3answers
36 views
Why doesn't this short bash script/function work? Possible solutions? (UNIX bash scripting)
I am trying to make an error message appear if someone runs my script but a file which doesn't exist is entered as an argument.
function finder(){
if test find $1 ; then
exit 0
else
exit 1
fi
}
...
1
vote
1answer
39 views
When should we change the IFS variable back to its original value in scripts?
Let's say I execute this script via a cronjob:
IFS=$'\n'
for i in `cat "$1"`; do
echo "$i" >> xtempfile.tmp;
done
It works fine without causing any issues. But when I run this in a ...
2
votes
1answer
43 views
Can someone explain this short getopts bash script in plain english? (UNIX)
This is the script:
file=$1
while getopts ":ivr" opt; do
case $opt in
i) iopt=1;;
v) vopt=1;;
r) ropt=1;;
\?)echo "invalid option: -$OPTARG" >
esac
done
shift $(($OPTIND-1))
So the only part I ...
0
votes
2answers
32 views
Filter non-alphabetic characters out of string in shell script
Very simple question but can't seem to find a simple answer...
I am writing a bash script which needs to remove all non-alphabetic and non-numeric characters. Eg. I want...
INPUT_STRING="ABC# ...
0
votes
2answers
39 views
Checking output of multiple variables in bash
Right now I have multiple commands defined as variables in my bash script like so:
LSIBATTSTATE=`/var/lib/einarc/tools/lsi_megacli/cli -AdpBbuCmd -GetBbuStatus -aALL | grep 'Operational'`
...
1
vote
1answer
31 views
parsing inputs to shell script on command line
I'm trying to assign everything else after strings to $@ but orange is also picked. I thought the shift will take as rest of the args but the output is picking orange too.
$ cat try.sh
...
0
votes
2answers
73 views
bash script unable to get the variable
On command line this works like this:
svn log "$src_url" --stop-on-copy \
| awk -v RS="--+" -F'|' ' /ticket-101/{print $1}' \
| grep "^r" \
| cut -d"r" -f2 \
| cut -d" " -f1
Output:
6359
...
0
votes
0answers
15 views
Passing parameter to FTP macro
I have developed a bash script that contains an FTP invocation.
Because the actions i do are based on a routine i have added a macro inside the .netrc
file in my home directory.
This is a small ...
0
votes
0answers
12 views
rdiff-backup errors: script keeps quitting with error
Ive recently been introduced to bash scripting... So, Ive used my advanced theft course to throw together the attached script. it runs... and exits with "/xxx/ not mounted. You are not root! I have ...