Menu

setting up a bash script to build progs and a print file

2023-08-26
2023-08-26
  • Vincent (Bryan) Coen

    Using Linux I have a bash script to build a lot of app progs but it has an issue, but first the script :

     #1st load the copybook path
    export COBCPY=/home/vince/cobolsrc/oe/src/copybook
    for i in `ls *.cbl`; do cobc -m $i -Wlinkage -T $i.prn; echo "Compiled " $i; done
    

    This find all files with extension of .cbl and compiles them BUT it also sets up the print file as progname.cbl.prn

    How do I change this script to give print files as progname.prn

    I did think there was a ls switch that would just give the name without the extension but does not seem to do this, next was, is there a way of using grep, but again no such feature.

    It is driving me nuts trying to find what I suspect is a simple fix :(

    Any one with a solution say within the for i in `ls etc ?

     
    • Simon Sobisch

      Simon Sobisch - 2023-08-26

      Or, during compile, change the output of a your sub-shell ls, or do that when referencing it (nowadays, prefer $(...) over `...`:

      for i in $(ls *.cbl |  cut -d. -f1); do cobc -m $i.cbl -Wlinkage -T $i.prn; echo "Compiled " $i; done
      
      for i in $(ls *.cbl); do cobc -m $i -Wlinkage -T $(echo $i |  cut -d. -f1).prn; echo "Compiled " $i; done
      

      and of course, if you use that more regularly, use a Makefile.
      With GC 3.2 you can (again) use -MT to also generate a dependency file, so if one copybook changes make would compile (all and only) the COBOL sources that use that.

       

      Last edit: Simon Sobisch 2023-08-26
  • Mickey White

    Mickey White - 2023-08-26

    Try this:

    for a in *cbl.prn; do mv $a `echo $a | sed 's/.prn//'`; done
    

    While you are in the directory that has the * . cbl.prn files

     

    Last edit: Mickey White 2023-08-26
    • Vincent (Bryan) Coen

      That crapped over all *.cbl file over writing o/p from the .prn reports.

      I will have to rebuild all of the programs.

      On 26/08/2023 20:03, Mickey White wrote:

      Try this:

      |forain*cbl.prn; do mv $a echo $a | sed 's/.prn//'; done |

      setting up a bash script to build progs and a print file
      https://sourceforge.net/p/gnucobol/discussion/help/thread/e6a6879714/?limit=25#a74b

       
  • Mickey White

    Mickey White - 2023-08-26

    Sorry the tic marks are not cut and pasting correctly. Did not see that...
    This is one I have on your compile line and it works, but there are TIC marks (the ` to the left of the number 1 key) before the echo and after the last sed single qoute.

    for i in ls *.cbl; do cobc -m $i -Wlinkage -T $i.prn; echo "Compiled " $i;mv $i.prn echo $i.prn | sed 's/cbl.prn/prn/'; done

    It is still not putting the tic mark there I will send it to you in email...

    THIS part should have a tic mark before the e in echo and after the last single qoute. I will put a caret there instaed but change it to tic.
    ^echo $i.prn | sed 's/cbl.prn/prn/'^

     

    Last edit: Mickey White 2023-08-26

Anonymous
Anonymous

Add attachments
Cancel