[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Determining a scripts language?
- Subject: [ale] Determining a scripts language?
- From: jim.kinney at gmail.com (Jim Kinney)
- Date: Wed, 06 Apr 2016 18:33:37 -0400
- In-reply-to: <CACv9p5pN_61HdAqoXRixTpzD1q5_pAC9Rw76-6iGmNfFR66O=A@mail.gmail.com>
- References: <CACv9p5pN_61HdAqoXRixTpzD1q5_pAC9Rw76-6iGmNfFR66O=A@mail.gmail.com>
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.
for myfile in $( find . -type f | head -n 10000 ); do file ${myfile} |
egrep -i script| egrep -v makefile; done?
./rpmbuild/BUILD/cinelerra/libmpeg3/make_package: POSIX shell script,
ASCII text executable
./rpmbuild/BUILD/cinelerra/libmpeg3/configure: POSIX shell script,
ASCII text executable
./rpmbuild/BUILD/cinelerra/libmpeg3/mpeg3cat: POSIX shell script, ASCII
text executable, with very long lines
./rpmbuild/BUILD/cinelerra/libmpeg3/make_rpm: POSIX shell script, ASCII
text executable
./rpmbuild/BUILD/cinelerra/libmpeg3/mpeg3toc: POSIX shell script, ASCII
text executable, with very long lines
./rpmbuild/BUILD/cinelerra/libmpeg3/mpeg3dump: POSIX shell script,
ASCII text executable, with very long lines
./rpmbuild/BUILD/cinelerra/config.sub: POSIX shell script, ASCII text
executable
./rpmbuild/BUILD/cinelerra/aclocal.m4: M4 macro processor script, ASCII
text, with very long lines
./rpmbuild/BUILD/cinelerra/libtool: POSIX shell script, ASCII text
executable
./rpmbuild/BUILD/cinelerra/cinelerra/gen-feather-h: Perl script, ASCII
text executable
Now to pull out the actual files
for myfile in $( find . -type f | head -n 10000 ) ?# I added the |head
-n 10000 to cut down of the file processing
? do myfullfile=$(file ${myfile} | egrep -i script| egrep -v makefile |
awk -F ':' '{print $1}')?
? ? mybasefile=$(basename ${myfullfile})
? ? mydirname=$(dirname ${myfullfile})
? ? mynewbase=$(echo ${mybasefile} | awk -F '.' '{$NF=""; print $0}' |
sed 's/ \+$/.txt/'
? ? cp ${myfullfile} ${mydirname}/${mynewbase}
done
I feel like the sed to scrap the trailing space for the .txt is a
kludge but the funky awk print adds the space.
? ??
On Wed, 2016-04-06 at 17:52 -0400, leam hall wrote:
> 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.?
>
> So far all I've some up with is:
>
> ? IS_SH=`echo ${SCRIPTNAME} | grep -c sh$`
>
> For each expected script ending. Which seems a really ugly thing to
> do. Is there a better way in Bourne shell to do this?
>
> Leam
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
--
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/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20160406/81f0af54/attachment.html>