Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: konsolebox
1,406
Posted By konsolebox
I'd do it this way: #!/bin/bash ...
I'd do it this way:

#!/bin/bash

USER=BARSPIN
HOTKEYS_PATH="/home/$USER/Documents/bash/tibia/HOTKEYS"

CFG[1]="A"
CFG[2]="B"
CFG[3]="C"
...

EXIT=0

if [[ -e $HOTKEYS_PATH ]]; then
...
1,715
Posted By konsolebox
Your simple code could even have an easy...
Your simple code could even have an easy variation as well. Simply removing ! would print those that are to be excluded instead. This is useful if they are to be deleted.
awk -F. 'a[$NF]++' a.txt
1,336
Posted By konsolebox
Or /^[[:alnum:]]+$/ /^[[:alpha:]][[:alnum:]]+$/
Or /^[[:alnum:]]+$/
/^[[:alpha:]][[:alnum:]]+$/
1,083
Posted By konsolebox
Well basically you'll have to check the file's...
Well basically you'll have to check the file's contents from time to time but using stat as the starting point would help save your disk from much IO.
865
Posted By konsolebox
It's also a good idea to quote your variables...
It's also a good idea to quote your variables properly:
w=`sed -e 's/\(.*!\)\(.*\)\(, Queue.*$\)/\2/' out.dat | awk '/'$1'/{n=0;{print $n}}' | head -n 1`
if [ "$1" = "$w" ]; then
x=`sed -e...
7,304
Posted By konsolebox
Try to call the shell instead: 35,40,45,50,55...
Try to call the shell instead:
35,40,45,50,55 04,05 07 08 * /path/to/sh /uv1402/u207/home/bravodba/bestdbscript/shscriptfiles/bravo_main_refresh.shIf sh is bash, then use bash.

Oh yes. The...
1,083
Posted By konsolebox
Use stat to get the modification timestamp of the...
Use stat to get the modification timestamp of the file and store it on a variable. Compare it later to check changes. Of course the filesystem should be consistent with updates. Some filesystem may...
7,225
Posted By konsolebox
Considering the use of FS and OFS I now have this...
Considering the use of FS and OFS I now have this version:
awk -v m=3 -v n=9 -v FS=, -v OFS=, -- '{
j = 0
for (i = 1; i <= NF; ++i) {
if (i == m || i == n) {
++j
...
788
Posted By konsolebox
What is the error shown? Also you could see...
What is the error shown?

Also you could see if you're getting the proper commands with cat:
cat <<-EOF
....
EOF
Or you could also use here strings:
sql command <<< "
...
"
7,225
Posted By konsolebox
I remember finding this bug but probably my...
I remember finding this bug but probably my modification didn't went through.

In the world of awk yes, but there's no way I would do that in C, and somehow doesn't make me want to do it in awk as...
1,510
Posted By konsolebox
You can't really do this unless you have a proper...
You can't really do this unless you have a proper end of section marker. If your end of section is a blank line but one of your values could sometimes be a blank as well then there's no way a script...
12,408
Posted By konsolebox
Speaking of gawk's extended match this is one way...
Speaking of gawk's extended match this is one way for that:
#!/usr/bin/gawk -f

{
if (match($0, /^[^\[]+\[([^ ]+).*xyz_session_id\/=([^ &]+)/, t)) {
k = t[1]; v = t[2]
a[k]...
1,575
Posted By konsolebox
Yes my example was just an example as well. You...
Yes my example was just an example as well. You could use your sql commands there. If you intend to send input instead you could make use of input process substitution instead (>()).
1,575
Posted By konsolebox
Yes you could use process substitution with exec:...
Yes you could use process substitution with exec:
exec 4< <(sleep 4s; echo A)
read -u 4 __
echo "$__"
exec 4<&-
If you're going to execute an external binary use exec:exec 4< <(exec yes)
7,225
Posted By konsolebox
The first and last columns won't have an extra...
The first and last columns won't have an extra pair of comma if they are deleted so FS "+" would not work. Also if one column was originally empty that column would also be deleted. It's better to...
2,030
Posted By konsolebox
I think it's best to use Perl and XML::Simple for...
I think it's best to use Perl and XML::Simple for that. Awk has limitations with non-multi-line need-parser-type based data.

---------- Post updated at 04:43 PM ---------- Previous update was at...
5,072
Posted By konsolebox
It's also cleaner to use arrays [code] ...
It's also cleaner to use arrays


[code]
#!/bin/bash

EXCLUDE=("Archive PST" "SystemState")

RSYNCEXCLUSIONS=()

for A in "${EXCLUDE[@]}"; do
RSYNCEXCLUSIONS[${#RSYNCEXCLUSIONS[@]}]=$A...
2,503
Posted By konsolebox
Some parts of your code expands words when a...
Some parts of your code expands words when a variable or a command exansion expands contents with spaces



for i in `find .` ; do # problem if a line has a space

............. $i...
10,807
Posted By konsolebox
you just have to close them then: ...
you just have to close them then:


#!/bin/bash

{
exec 62>&-
exec 63>&-
lvcreate -s -l 100%FREE -n var-data-snapshot vg00/var-data
} 2> >(logger -t "loggingtest.crit") 1> >(logger -t...
12,990
Posted By konsolebox
Try to run this on a script. You should be on the...
Try to run this on a script. You should be on the parent directory of content and google_ads

#!/bin/bash

function main {
while read LINE; do
LINE=${LINE#*/}
echo "creating directory...
3,048
Posted By konsolebox
If you're nodes are separated by lines, a safer...
If you're nodes are separated by lines, a safer method would be:

HOST_FILE=<your path to host file>

NODES=()

while read; do
NODES[${#NODES[@]}]=$REPLY
done < "$HOST_FILE"
...
4,893
Posted By konsolebox
I don't really get what you're after but here's...
I don't really get what you're after but here's some hint for bash:
#!/bin/bash

CONFIGFILE=<path to file>
LOGFILE=<path to log file>

read URL < "$CONFIGFILE"

echo "Fetching $URL..."
wget...
10,085
Posted By konsolebox
sed '/\(.*\)[[:blank:]]\+\1$/{ s/.*/same/; b; };...
sed '/\(.*\)[[:blank:]]\+\1$/{ s/.*/same/; b; }; s/.*/not-same/;' file
10,085
Posted By konsolebox
another way: sed '/\(.*\) \1$/{ s/.*/same/; b;...
another way:
sed '/\(.*\) \1$/{ s/.*/same/; b; }; s/.*/not-same/;' file
2,546
Posted By konsolebox
I know some of ksh but I'm not yet used to it so...
I know some of ksh but I'm not yet used to it so I wrote this in bash. I hope you at least get the concept:

#!/bin/bash

LOGFILE=<path to logfile>

C0=$(fgrep -c 'Connection Error'...
Showing results 1 to 25 of 48

 

Featured Tech Videos

All times are GMT -4. The time now is 10:23 PM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy