Search Results

Search: Posts Made By: tkleczek
3,114
Posted By tkleczek
When you ask question, try to be more precise....
When you ask question, try to be more precise. What kind of problems have you been facing? Your code doesn't produce any errors. Each time the 'CODE' variable is tested in 'case' construct, there is...
6,422
Posted By tkleczek
The following should do the trick: find ....
The following should do the trick:

find . -name "esi01v*" -type f -daystart -mtime 0
30,524
Posted By tkleczek
Out=/dfezz1/output.txt Node="'LPAR Info:'" ...
Out=/dfezz1/output.txt
Node="'LPAR Info:'"
Gr3p0=" |grep"
Printc=" prtconf"
Output1=" | tee -a $Out"
Cat1="cat /dfezz1/tmp.txt"

cmd="$Cat1 $Gr3p0 $Node $Output1"
eval VAR=\$\($cmd\)
30,524
Posted By tkleczek
Oh, right. But that's the result of redirecting...
Oh, right. But that's the result of redirecting the output. If you want the result of the command to be both written to a file and printed to the standard output, use 'tee' command.
44,738
Posted By tkleczek
awk -v FS='|' ' NR == FNR { arr[$1]=$2; next } ...
awk -v FS='|' ' NR == FNR { arr[$1]=$2; next }
{
for (str in arr)
gsub(str,arr[str])
print $0
}' data_file input_file

data_file has the format

string1|replacement for...
30,524
Posted By tkleczek
Try: cmd="$Cat1 $Gr3p0 $Node $Output1" ...
Try:

cmd="$Cat1 $Gr3p0 $Node $Output1"
eval VAR=\$\($cmd\)
8,080
Posted By tkleczek
find "$dir_name" -name 'out_*'
find "$dir_name" -name 'out_*'
19,098
Posted By tkleczek
The following is a bit shorter and allows an...
The following is a bit shorter and allows an arbitrary number of folders

#!/bin/bash
i=1
for f in *.TIF; do
mv "$f" "folder$i/"
((i=i%3+1))
done
11,159
Posted By tkleczek
for f in pi-*.pdf; do mv "$f" "pi-$(echo "$f"...
for f in pi-*.pdf; do
mv "$f" "pi-$(echo "$f" | cut -c 4-7 | tr '[a-z]' '[A-Z]').pdf"
done
3,988
Posted By tkleczek
You can try alaso awk solution: awk -v...
You can try alaso awk solution:

awk -v FS=',' -v OFS=',' '{
if ($2 ~ /^[0-9]*$/)
print $0
else
print $0 >> "err_file"
}' input_file
48,890
Posted By tkleczek
There are many ways to achieve your goal,...
There are many ways to achieve your goal, consider the following two:

var="dir1 dir2 dir3"
for dir in $var; do
echo "$dir"
done



arr=(dir1 dir2 dir3)
n=0
while (( n < ${#arr } ));...
3,767
Posted By tkleczek
Yes, and you can initialize the array from...
Yes, and you can initialize the array from positional parameters even more elegantly:

args=("$@")
16,705
Posted By tkleczek
When a process that is on the left side of the...
When a process that is on the left side of the pipe writes some output and the process on the right has exited, the SIGPIPE signal is passed to the left process. If it is not handled, the default...
3,767
Posted By tkleczek
You can always pass all the script arguments to a...
You can always pass all the script arguments to a function..

fn "$@"

By default, variables are global in the subshell in which they are created.
If you want to define a variable in a function...
3,992
Posted By tkleczek
Try the following: awk -v FS='|' -v OFS='|'...
Try the following:

awk -v FS='|' -v OFS='|' '{
if (substr($1,1,3) == "MIR") {
mir=1
$2="TEST"
}
else if (mir == 1) {
$6="25"
mir=0
}
...
4,433
Posted By tkleczek
Another pure sed, a bit shorter sed -n 'H; $...
Another pure sed, a bit shorter

sed -n 'H; $ {g; s/\n//g; s/\\t\\t/\n/g; s/\\t//g; p; }' input_file
3,965
Posted By tkleczek
while read first rest; do echo "$first...
while read first rest; do
echo "$first $rest" >> $first.txt
done


Side effect: It changes all whitespace between first and second field into space.
3,124
Posted By tkleczek
You could find the following command useful: ...
You could find the following command useful:


tail -f log_file | script_handling_job_completions &
27,953
Posted By tkleczek
This should do it. BEGIN { i=0; j=0 } FNR...
This should do it.

BEGIN { i=0; j=0 }
FNR == NR { a[i++]=$0; next }
{
if (a[j] != $0) b[j]=1; else b[j]=0;
j++;
}
END {
print "from file 1"
for (k=0; k < i; ++k) if...
11,309
Posted By tkleczek
Well, i checked this code against your example,...
Well, i checked this code against your example, and it seems to work properly.


#!/bin/sed -f
h
s/\("[^",]*\),\?\([^"]*"\)/\1\2/g
x;G;:c;tc
s/^\(.*\)\n\1$/\1/
t
D
6,177
Posted By tkleczek
The following should do. sed ' :a ...
The following should do.


sed '
:a
s/\([^(]*([^)#]*\)#\([^)]*).*\)/\1 \2/g
ta
' input_file
11,309
Posted By tkleczek
I've come up with the following code for the...
I've come up with the following code for the multicomas case.

#!/bin/sed -f
h
s/\("[^",]*\),\?\([^"]*"\)/\1\2/g
x;G;:c;tc
s/^\(.*\)\n\1$/\1/
t
D

It's a bit clumsy, but i cannot...
6,177
Posted By tkleczek
I thought, that's what you want. Please specify...
I thought, that's what you want. Please specify once again the input and the output you should want to receive.
5,399
Posted By tkleczek
Try following sed script: #!/bin/sed -f ...
Try following sed script:

#!/bin/sed -f
1h
1!{
x
G
s/\([[:alnum:]]\+\)\>.*\n\1\(.*\)/\t\2/i
s/.*\n//
}
11,309
Posted By tkleczek
Try the following code: #!/bin/sed -f ...
Try the following code:

#!/bin/sed -f
s/"\([^"]*\)*"/"1\1"2/g
s/"1\([^",]*\),\([^"]*\)"2/\1\2/g
s/".//g


The above code will work on assumption that there is at most one coma in...
Showing results 1 to 25 of 34

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