Storing result in variable (unix shell script) [on hold]












-3















In the script below, I am able to get result till job(line no-5) properly. I am getting correct result in /tmp/jobname.txt file.
However, I am getting error while storing result in startime variable.
I know the syntax head -1 $i is incorrect. I to pass that $i variable. file starttime.log is getting created with 0 byt.e due to syntax issue



#!/bin/ksh
tlog=`tail -1 /tmp/jobname.txt`
job=`grep STARTED "newco_dm_multischema.log" | sort -u | awk '{print $7}' > /tmp/jobname.txt`
starttime=`grep -B1 $tlog "newco_dm_multischema.log" | head -1 $i | awk '{print $1,$2}' | cut -c 2,20 > /tmp/starttime.log`
done









share|improve this question









New contributor




user2429695 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as unclear what you're asking by andcoz, Anthony Geoghegan, Jeff Schaller, ilkkachu, Christopher 4 hours ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 2





    Hi and welcome to U&L Stack Exchange. What error are you getting?

    – Time4Tea
    9 hours ago






  • 4





    Why did you delete your original question and then ask almost the same one totally ignoring my suggestions.

    – RoVo
    8 hours ago








  • 3





    Please explain why you're using a loop here at all. It's really hard to tell what you're trying to do.

    – RoVo
    8 hours ago






  • 1





    I recommend starting from scratch with a very simple 1-line command and make sure you know how to store the result of a command to a file. Then, build up from there. I don't know ksh, so not 100% sure of the syntax.

    – Time4Tea
    8 hours ago






  • 2





    Your code contains multiple issues. Try to write a simple example of the one issue you need help with. This will help you to isolate the problem and us to understand it.

    – andcoz
    6 hours ago
















-3















In the script below, I am able to get result till job(line no-5) properly. I am getting correct result in /tmp/jobname.txt file.
However, I am getting error while storing result in startime variable.
I know the syntax head -1 $i is incorrect. I to pass that $i variable. file starttime.log is getting created with 0 byt.e due to syntax issue



#!/bin/ksh
tlog=`tail -1 /tmp/jobname.txt`
job=`grep STARTED "newco_dm_multischema.log" | sort -u | awk '{print $7}' > /tmp/jobname.txt`
starttime=`grep -B1 $tlog "newco_dm_multischema.log" | head -1 $i | awk '{print $1,$2}' | cut -c 2,20 > /tmp/starttime.log`
done









share|improve this question









New contributor




user2429695 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as unclear what you're asking by andcoz, Anthony Geoghegan, Jeff Schaller, ilkkachu, Christopher 4 hours ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 2





    Hi and welcome to U&L Stack Exchange. What error are you getting?

    – Time4Tea
    9 hours ago






  • 4





    Why did you delete your original question and then ask almost the same one totally ignoring my suggestions.

    – RoVo
    8 hours ago








  • 3





    Please explain why you're using a loop here at all. It's really hard to tell what you're trying to do.

    – RoVo
    8 hours ago






  • 1





    I recommend starting from scratch with a very simple 1-line command and make sure you know how to store the result of a command to a file. Then, build up from there. I don't know ksh, so not 100% sure of the syntax.

    – Time4Tea
    8 hours ago






  • 2





    Your code contains multiple issues. Try to write a simple example of the one issue you need help with. This will help you to isolate the problem and us to understand it.

    – andcoz
    6 hours ago














-3












-3








-3








In the script below, I am able to get result till job(line no-5) properly. I am getting correct result in /tmp/jobname.txt file.
However, I am getting error while storing result in startime variable.
I know the syntax head -1 $i is incorrect. I to pass that $i variable. file starttime.log is getting created with 0 byt.e due to syntax issue



#!/bin/ksh
tlog=`tail -1 /tmp/jobname.txt`
job=`grep STARTED "newco_dm_multischema.log" | sort -u | awk '{print $7}' > /tmp/jobname.txt`
starttime=`grep -B1 $tlog "newco_dm_multischema.log" | head -1 $i | awk '{print $1,$2}' | cut -c 2,20 > /tmp/starttime.log`
done









share|improve this question









New contributor




user2429695 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












In the script below, I am able to get result till job(line no-5) properly. I am getting correct result in /tmp/jobname.txt file.
However, I am getting error while storing result in startime variable.
I know the syntax head -1 $i is incorrect. I to pass that $i variable. file starttime.log is getting created with 0 byt.e due to syntax issue



#!/bin/ksh
tlog=`tail -1 /tmp/jobname.txt`
job=`grep STARTED "newco_dm_multischema.log" | sort -u | awk '{print $7}' > /tmp/jobname.txt`
starttime=`grep -B1 $tlog "newco_dm_multischema.log" | head -1 $i | awk '{print $1,$2}' | cut -c 2,20 > /tmp/starttime.log`
done






shell-script ksh






share|improve this question









New contributor




user2429695 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




user2429695 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 6 hours ago









Rui F Ribeiro

39.5k1479133




39.5k1479133






New contributor




user2429695 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 9 hours ago









user2429695user2429695

12




12




New contributor




user2429695 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user2429695 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user2429695 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as unclear what you're asking by andcoz, Anthony Geoghegan, Jeff Schaller, ilkkachu, Christopher 4 hours ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






put on hold as unclear what you're asking by andcoz, Anthony Geoghegan, Jeff Schaller, ilkkachu, Christopher 4 hours ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 2





    Hi and welcome to U&L Stack Exchange. What error are you getting?

    – Time4Tea
    9 hours ago






  • 4





    Why did you delete your original question and then ask almost the same one totally ignoring my suggestions.

    – RoVo
    8 hours ago








  • 3





    Please explain why you're using a loop here at all. It's really hard to tell what you're trying to do.

    – RoVo
    8 hours ago






  • 1





    I recommend starting from scratch with a very simple 1-line command and make sure you know how to store the result of a command to a file. Then, build up from there. I don't know ksh, so not 100% sure of the syntax.

    – Time4Tea
    8 hours ago






  • 2





    Your code contains multiple issues. Try to write a simple example of the one issue you need help with. This will help you to isolate the problem and us to understand it.

    – andcoz
    6 hours ago














  • 2





    Hi and welcome to U&L Stack Exchange. What error are you getting?

    – Time4Tea
    9 hours ago






  • 4





    Why did you delete your original question and then ask almost the same one totally ignoring my suggestions.

    – RoVo
    8 hours ago








  • 3





    Please explain why you're using a loop here at all. It's really hard to tell what you're trying to do.

    – RoVo
    8 hours ago






  • 1





    I recommend starting from scratch with a very simple 1-line command and make sure you know how to store the result of a command to a file. Then, build up from there. I don't know ksh, so not 100% sure of the syntax.

    – Time4Tea
    8 hours ago






  • 2





    Your code contains multiple issues. Try to write a simple example of the one issue you need help with. This will help you to isolate the problem and us to understand it.

    – andcoz
    6 hours ago








2




2





Hi and welcome to U&L Stack Exchange. What error are you getting?

– Time4Tea
9 hours ago





Hi and welcome to U&L Stack Exchange. What error are you getting?

– Time4Tea
9 hours ago




4




4





Why did you delete your original question and then ask almost the same one totally ignoring my suggestions.

– RoVo
8 hours ago







Why did you delete your original question and then ask almost the same one totally ignoring my suggestions.

– RoVo
8 hours ago






3




3





Please explain why you're using a loop here at all. It's really hard to tell what you're trying to do.

– RoVo
8 hours ago





Please explain why you're using a loop here at all. It's really hard to tell what you're trying to do.

– RoVo
8 hours ago




1




1





I recommend starting from scratch with a very simple 1-line command and make sure you know how to store the result of a command to a file. Then, build up from there. I don't know ksh, so not 100% sure of the syntax.

– Time4Tea
8 hours ago





I recommend starting from scratch with a very simple 1-line command and make sure you know how to store the result of a command to a file. Then, build up from there. I don't know ksh, so not 100% sure of the syntax.

– Time4Tea
8 hours ago




2




2





Your code contains multiple issues. Try to write a simple example of the one issue you need help with. This will help you to isolate the problem and us to understand it.

– andcoz
6 hours ago





Your code contains multiple issues. Try to write a simple example of the one issue you need help with. This will help you to isolate the problem and us to understand it.

– andcoz
6 hours ago










0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Loup dans la culture

How to solve the problem of ntp “Unable to contact time server” from KDE?

ASUS Zenbook UX433/UX333 — Configure Touchpad-embedded numpad on Linux