for loop in nohup
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am trying to run bash script which run 8 for loops simulatenously.
one of the my for loop likes below
for i in 00 01 02 03 04 ; do cat $INDIR/sys*$1.$i*csv | awk -F 'xac' 'BEGINOFS=";"; ($4 == 10) $1=$1; print '> $OUTDIR/$1_$i.csv
So I have converted into following syntax to run with nohup
nohup bash -c 'for i in 00 01 02 03 04; do cat $INDIR/rti*$1.$i*csv|awk -F '\xac' 'BEGINOFS=";"; ($4==10) $1=$1; print '>$OUTDIR/$i.csv;done' &
But I am getting following error
test.sh: line 9: syntax error near unexpected token `('
test.sh: line 9: `nohup bash -c 'for i in 00 01 02 03 04; do cat $INDIR/rti*$1.$i*csv|awk -F '\xac' 'BEGINOFS=";"; ($4==10) $1=$1; print '>$OUTDIR/$i.csv;done' & '
I also tried with following code changes
nohup sh -c ''
nohup /bin/bash -c ''
'xac'
but no progress,
BTW my for loop works without nohup
Thanks for your help
shell-script nohup
add a comment |Â
up vote
0
down vote
favorite
I am trying to run bash script which run 8 for loops simulatenously.
one of the my for loop likes below
for i in 00 01 02 03 04 ; do cat $INDIR/sys*$1.$i*csv | awk -F 'xac' 'BEGINOFS=";"; ($4 == 10) $1=$1; print '> $OUTDIR/$1_$i.csv
So I have converted into following syntax to run with nohup
nohup bash -c 'for i in 00 01 02 03 04; do cat $INDIR/rti*$1.$i*csv|awk -F '\xac' 'BEGINOFS=";"; ($4==10) $1=$1; print '>$OUTDIR/$i.csv;done' &
But I am getting following error
test.sh: line 9: syntax error near unexpected token `('
test.sh: line 9: `nohup bash -c 'for i in 00 01 02 03 04; do cat $INDIR/rti*$1.$i*csv|awk -F '\xac' 'BEGINOFS=";"; ($4==10) $1=$1; print '>$OUTDIR/$i.csv;done' & '
I also tried with following code changes
nohup sh -c ''
nohup /bin/bash -c ''
'xac'
but no progress,
BTW my for loop works without nohup
Thanks for your help
shell-script nohup
The root issue here is the single quotes, backslashes don't work inside them, so you have'for ...|awk -F '
quoted, then the rest is unquoted since the following single-quotes are all escaped.
â ilkkachu
Dec 6 '17 at 20:22
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to run bash script which run 8 for loops simulatenously.
one of the my for loop likes below
for i in 00 01 02 03 04 ; do cat $INDIR/sys*$1.$i*csv | awk -F 'xac' 'BEGINOFS=";"; ($4 == 10) $1=$1; print '> $OUTDIR/$1_$i.csv
So I have converted into following syntax to run with nohup
nohup bash -c 'for i in 00 01 02 03 04; do cat $INDIR/rti*$1.$i*csv|awk -F '\xac' 'BEGINOFS=";"; ($4==10) $1=$1; print '>$OUTDIR/$i.csv;done' &
But I am getting following error
test.sh: line 9: syntax error near unexpected token `('
test.sh: line 9: `nohup bash -c 'for i in 00 01 02 03 04; do cat $INDIR/rti*$1.$i*csv|awk -F '\xac' 'BEGINOFS=";"; ($4==10) $1=$1; print '>$OUTDIR/$i.csv;done' & '
I also tried with following code changes
nohup sh -c ''
nohup /bin/bash -c ''
'xac'
but no progress,
BTW my for loop works without nohup
Thanks for your help
shell-script nohup
I am trying to run bash script which run 8 for loops simulatenously.
one of the my for loop likes below
for i in 00 01 02 03 04 ; do cat $INDIR/sys*$1.$i*csv | awk -F 'xac' 'BEGINOFS=";"; ($4 == 10) $1=$1; print '> $OUTDIR/$1_$i.csv
So I have converted into following syntax to run with nohup
nohup bash -c 'for i in 00 01 02 03 04; do cat $INDIR/rti*$1.$i*csv|awk -F '\xac' 'BEGINOFS=";"; ($4==10) $1=$1; print '>$OUTDIR/$i.csv;done' &
But I am getting following error
test.sh: line 9: syntax error near unexpected token `('
test.sh: line 9: `nohup bash -c 'for i in 00 01 02 03 04; do cat $INDIR/rti*$1.$i*csv|awk -F '\xac' 'BEGINOFS=";"; ($4==10) $1=$1; print '>$OUTDIR/$i.csv;done' & '
I also tried with following code changes
nohup sh -c ''
nohup /bin/bash -c ''
'xac'
but no progress,
BTW my for loop works without nohup
Thanks for your help
shell-script nohup
edited Dec 6 '17 at 12:53
asked Dec 6 '17 at 12:48
Murat
256
256
The root issue here is the single quotes, backslashes don't work inside them, so you have'for ...|awk -F '
quoted, then the rest is unquoted since the following single-quotes are all escaped.
â ilkkachu
Dec 6 '17 at 20:22
add a comment |Â
The root issue here is the single quotes, backslashes don't work inside them, so you have'for ...|awk -F '
quoted, then the rest is unquoted since the following single-quotes are all escaped.
â ilkkachu
Dec 6 '17 at 20:22
The root issue here is the single quotes, backslashes don't work inside them, so you have
'for ...|awk -F '
quoted, then the rest is unquoted since the following single-quotes are all escaped.â ilkkachu
Dec 6 '17 at 20:22
The root issue here is the single quotes, backslashes don't work inside them, so you have
'for ...|awk -F '
quoted, then the rest is unquoted since the following single-quotes are all escaped.â ilkkachu
Dec 6 '17 at 20:22
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
It would be much easier (read: more read- and maintainable) if you divide your code into two scripts: One to execute the actual function(s), and one to start them. Sample code for the latter:
for i in 00 01 02 03 04; do
nohup /path/to/workerScript.sh $i
done
If you want to keep the logic in a single script you can still use this approach:
if [ $# -eq 0 ]; then
for i in 00 01 02 03 04; do
nohup $0 $i
done
exit 0
fi
# Rest of the logic follows
Hello Murphy I already have this solution and it works very well. But I am looking one script way :) thanks for your reply
â Murat
Dec 8 '17 at 12:49
@Murat You can have that and still keep the script readable. I expanded my example.
â Murphy
Dec 8 '17 at 13:02
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
It would be much easier (read: more read- and maintainable) if you divide your code into two scripts: One to execute the actual function(s), and one to start them. Sample code for the latter:
for i in 00 01 02 03 04; do
nohup /path/to/workerScript.sh $i
done
If you want to keep the logic in a single script you can still use this approach:
if [ $# -eq 0 ]; then
for i in 00 01 02 03 04; do
nohup $0 $i
done
exit 0
fi
# Rest of the logic follows
Hello Murphy I already have this solution and it works very well. But I am looking one script way :) thanks for your reply
â Murat
Dec 8 '17 at 12:49
@Murat You can have that and still keep the script readable. I expanded my example.
â Murphy
Dec 8 '17 at 13:02
add a comment |Â
up vote
2
down vote
It would be much easier (read: more read- and maintainable) if you divide your code into two scripts: One to execute the actual function(s), and one to start them. Sample code for the latter:
for i in 00 01 02 03 04; do
nohup /path/to/workerScript.sh $i
done
If you want to keep the logic in a single script you can still use this approach:
if [ $# -eq 0 ]; then
for i in 00 01 02 03 04; do
nohup $0 $i
done
exit 0
fi
# Rest of the logic follows
Hello Murphy I already have this solution and it works very well. But I am looking one script way :) thanks for your reply
â Murat
Dec 8 '17 at 12:49
@Murat You can have that and still keep the script readable. I expanded my example.
â Murphy
Dec 8 '17 at 13:02
add a comment |Â
up vote
2
down vote
up vote
2
down vote
It would be much easier (read: more read- and maintainable) if you divide your code into two scripts: One to execute the actual function(s), and one to start them. Sample code for the latter:
for i in 00 01 02 03 04; do
nohup /path/to/workerScript.sh $i
done
If you want to keep the logic in a single script you can still use this approach:
if [ $# -eq 0 ]; then
for i in 00 01 02 03 04; do
nohup $0 $i
done
exit 0
fi
# Rest of the logic follows
It would be much easier (read: more read- and maintainable) if you divide your code into two scripts: One to execute the actual function(s), and one to start them. Sample code for the latter:
for i in 00 01 02 03 04; do
nohup /path/to/workerScript.sh $i
done
If you want to keep the logic in a single script you can still use this approach:
if [ $# -eq 0 ]; then
for i in 00 01 02 03 04; do
nohup $0 $i
done
exit 0
fi
# Rest of the logic follows
edited Dec 8 '17 at 13:01
answered Dec 6 '17 at 13:11
Murphy
1,7471517
1,7471517
Hello Murphy I already have this solution and it works very well. But I am looking one script way :) thanks for your reply
â Murat
Dec 8 '17 at 12:49
@Murat You can have that and still keep the script readable. I expanded my example.
â Murphy
Dec 8 '17 at 13:02
add a comment |Â
Hello Murphy I already have this solution and it works very well. But I am looking one script way :) thanks for your reply
â Murat
Dec 8 '17 at 12:49
@Murat You can have that and still keep the script readable. I expanded my example.
â Murphy
Dec 8 '17 at 13:02
Hello Murphy I already have this solution and it works very well. But I am looking one script way :) thanks for your reply
â Murat
Dec 8 '17 at 12:49
Hello Murphy I already have this solution and it works very well. But I am looking one script way :) thanks for your reply
â Murat
Dec 8 '17 at 12:49
@Murat You can have that and still keep the script readable. I expanded my example.
â Murphy
Dec 8 '17 at 13:02
@Murat You can have that and still keep the script readable. I expanded my example.
â Murphy
Dec 8 '17 at 13:02
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f409199%2ffor-loop-in-nohup%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
The root issue here is the single quotes, backslashes don't work inside them, so you have
'for ...|awk -F '
quoted, then the rest is unquoted since the following single-quotes are all escaped.â ilkkachu
Dec 6 '17 at 20:22