Tagged Questions
0
votes
2answers
63 views
search fitting ipv6 address for MAC-Address in neighbours
I have a list of possible to ip6 addresses converted MAC-addresses, that could be found in the output of
ping6 ff02::1%wlan0
possible mac addresses are for example:
66:70:02:75:80:fe, ...
2
votes
2answers
145 views
Testing a string containing only spaces (tabs, or “ ”)?
My code below doesn't work:
stringZ=" "
if [[ "$stringZ" == ^[[:blank:]][[:blank:]]*$ ]];then
echo string is blank
else
echo string is not blank
fi
Result:
string is not blank # wrong
...
5
votes
2answers
422 views
Extracting a string, according to a pattern, in a bash script
In bash, suppose that I have a string strname:
strname="ph7go04325r"
I would like to extract the characters between the first "3" character and the last "r" character in strname, saving the result ...
1
vote
4answers
5k views
Splitting string by the first occurrence of a delimiter
I have a string in the next format
id;some text here with possible ; inside
and want to split it to 2 strings by first occurrence of the ;. So, it should be: id and some text here with possible ; ...
2
votes
3answers
304 views
Find word in sentence with Bourne Shell (sh)
I'm trying to determine if a particular word appears in a sentence using Bourne Shell (sh). For example:
#!/bin/bash
INPUT='Lorem ipsum dolor sit amet.'
if [[ "$INPUT" == *dolor* ]]
then
echo ...
5
votes
2answers
587 views
Splitting bash command line argument
Is this the best way to split up a colon separated bash command line argument?
#!/bin/bash
hostlist=`echo $1| awk '{split($0,Ip,":")} END{for (var in Ip) print Ip[var];}'`
for host in $hostlist
do
...
0
votes
2answers
217 views
Checking if PATH contains $HOME/mydir and adding it if not (all in a script) [duplicate]
Possible Duplicate:
keep duplicates out of $PATH on source
I am not an expert with Unix scripting. Some of my scripts are located in $HOME/mydir. Unfortunately, they are not accessible from ...
6
votes
7answers
736 views
Bash - Continuous String Manipulation
#!/bin/bash
FILE="$(basename "$1")"
FILE="${FILE/%.jpeg/.jpg}"
Is there anyway to glue these two lines together into a one-liner?
2
votes
2answers
4k views
Bash shell script to locate and remove substring within a filename
I am trying to write a bash shell script in Mac OS X 10.6 (which is called by an Automator Action) to rename TV show DVD rips that I have named badly over the years. I want to remove part of the text ...