<html><head></head><body><div>the file command will give you details about what type of file. That is an easy way to determine if it's a script file.</div><div><br></div><div>for myfile in $( find . -type f | head -n 10000 ); do file ${myfile} | egrep -i script| egrep -v makefile; done </div><div>./rpmbuild/BUILD/cinelerra/libmpeg3/make_package: POSIX shell script, ASCII text executable</div><div>./rpmbuild/BUILD/cinelerra/libmpeg3/configure: POSIX shell script, ASCII text executable</div><div>./rpmbuild/BUILD/cinelerra/libmpeg3/mpeg3cat: POSIX shell script, ASCII text executable, with very long lines</div><div>./rpmbuild/BUILD/cinelerra/libmpeg3/make_rpm: POSIX shell script, ASCII text executable</div><div>./rpmbuild/BUILD/cinelerra/libmpeg3/mpeg3toc: POSIX shell script, ASCII text executable, with very long lines</div><div>./rpmbuild/BUILD/cinelerra/libmpeg3/mpeg3dump: POSIX shell script, ASCII text executable, with very long lines</div><div>./rpmbuild/BUILD/cinelerra/config.sub: POSIX shell script, ASCII text executable</div><div>./rpmbuild/BUILD/cinelerra/aclocal.m4: M4 macro processor script, ASCII text, with very long lines</div><div>./rpmbuild/BUILD/cinelerra/libtool: POSIX shell script, ASCII text executable</div><div>./rpmbuild/BUILD/cinelerra/cinelerra/gen-feather-h: Perl script, ASCII text executable</div><div><br></div><div>Now to pull out the actual files</div><div>for myfile in $( find . -type f | head -n 10000 ) # I added the |head -n 10000 to cut down of the file processing</div><div> do myfullfile=$(file ${myfile} | egrep -i script| egrep -v makefile | awk -F ':' '{print $1}') </div><div> mybasefile=$(basename ${myfullfile})</div><div> mydirname=$(dirname ${myfullfile})</div><div> mynewbase=$(echo ${mybasefile} | awk -F '.' '{$NF=""; print $0}' | sed 's/ \+$/.txt/'</div><div> cp ${myfullfile} ${mydirname}/${mynewbase}</div><div>done</div><div><br></div><div>I feel like the sed to scrap the trailing space for the .txt is a kludge but the funky awk print adds the space.</div><div><br></div><div> </div><div>On Wed, 2016-04-06 at 17:52 -0400, leam hall wrote:</div><blockquote type="cite"><div dir="ltr"><div><div><div>I'm trying to do something simple, change the ending of a script to ".txt". So if it's my_script.sh it becomes my_script.txt. Likewise for my_script.rb, etc. The .txt version will have the documentation and comments. <br><br></div>So far all I've some up with is:<br><br> IS_SH=`echo ${SCRIPTNAME} | grep -c sh$`<br><br></div>For each expected script ending. Which seems a really ugly thing to do. Is there a better way in Bourne shell to do this?<br><br></div>Leam<br clear="all"><div><div><div><div><div><br><pre>_______________________________________________
Ale mailing list
<a href="mailto:Ale@ale.org">Ale@ale.org</a>
<a href="http://mail.ale.org/mailman/listinfo/ale">http://mail.ale.org/mailman/listinfo/ale</a>
See JOBS, ANNOUNCE and SCHOOLS lists at
<a href="http://mail.ale.org/mailman/listinfo">http://mail.ale.org/mailman/listinfo</a>
</pre></div></div></div></div></div></div></blockquote><div><span><pre>--
James P. Kinney III
Every time you stop a school, you will have to build a jail. What you
gain at one end you lose at the other. It's like feeding a dog on his
own tail. It won't fatten the dog.
- Speech 11/23/1900 Mark Twain
http://heretothereideas.blogspot.com/
</pre></span></div></body></html>