The string tag has no wiki summary.
3
votes
2answers
127 views
Bash : compare two strings with space
I am trying to write a bash script which run a command and compare the result with another string.
#!/bin/bash -x
STATUS=`/root/setup_ha show --password-file=/root/password | grep ">HA State" | ...
1
vote
3answers
48 views
splitting the string in bash script
I am new to bash script. I am taking some input from user and checking details about that.
Example:
$HOME/Documents/test/one.txt
I take the above string as an input and want to retrieve one.txt, I ...
1
vote
0answers
26 views
Automatic replacement of strings in gedit
I want to replace some strings defined by me in gedit, after a word has been completed and/or the document has been saved. For example \ðrac should be replaced with \frac
How do I do this in gedit or ...
0
votes
2answers
63 views
Transform list of files (with date) into list of dates
I have a directory where I store backups. The are in the format Complete Backup YYYY-MM-DD hh-mm-ss.tar.bz2 I have found out that you can feed a date into the date command using date --date="YY-MM-DD ...
3
votes
5answers
92 views
Comparing Indices of two strings
I have two double quoted strings of same length, that look like this:
"$con" - (consists of spaces and *'s):
* ****** *** ** * **
and ...
2
votes
4answers
136 views
Can awk use field identifiers also for shell strings (variables)?
Well, this apparently is not possible the way I'm trying it.
This alternate approach to obtain bar as a resulting string works, though:
#!/bin/bash
path1=/usr/tmp/foo/bar/baz
awk -F/ '{print $5}' ...
0
votes
2answers
92 views
Extract a sub-string out of a variable's value
I have a string in the form of segment_78787 which is stored in a variable called $ID in my shell script. I need to get the second part "78787" and assign it to another variable.
I tried like
...
2
votes
1answer
46 views
strings command printing some extra characters
I am trying to capture mysql traffic using tcpdump and converting it to text using strings command, but while capturing mysql traffic, I am getting some extra character at the end of each character. I ...
2
votes
1answer
112 views
IPTables string match redirection
The issue: I am currently redirecting port 80 requests to another system on port 1000.
This is done like so:
iptables -t nat -A PREROUTING ! -s 172.20.1.2 -p tcp --dport 80 -j DNAT --to-destination ...
4
votes
2answers
148 views
Convert MAC address to Link-local address with bash
How can I convert a Mac address into an ipv6 Link-Local address?
you have to add fe80:: at the start and insert ff:fe in the middle
furthermore all leading zeros must be stripped
0
votes
2answers
113 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
1answer
80 views
shell parameter substitution to rename files
I need to rename filenames which starts with "foo" into "boo"
This is the script I used
#!/bin/sh
for f in *.jpg;
do
mv -- "{$f}" "${f/foo/boo}";
done
but when i run I get a bad substitution ...
2
votes
2answers
361 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
...
3
votes
3answers
3k views
How to get the first word of a string?
When I 'echo *' I get the following output:
file1 file2 file3 ...
What I want is to pick out the first word. How can I proceed?
0
votes
3answers
150 views
Extract the base file name from a URL
url=http://www.foo.bar/file.ext; echo ${url##/*}
I expected this code to print file.ext, but it prints the whole URL. Why? How can I extract the file name?