[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UNIX/Apple textfile/newline problems? Some remedies follow..



Yet more corrections..

In article <Aug22.210155.29499@acs.ucalgary.ca>
sbdocker@acs.ucalgary.ca (Sean Brendan Dockery) writes:

| ----------------------- striplf (ksh version) -----------------------
| #!/bin/ksh
| 
| # striplf (ksh version): strip UNIX newlines from a file that has had
| #  line lengths truncated to 255 characters.
| 
| if [ $# = 0 ] ; then
| 	echo "usage: ${0##*/} <filespec>"
| 	exit 1
| fi
| 
| for file in $*
  ^^^^^^^^^^^^^^

Change to 'for file in $* ; do'

| 	cat $file | tr -d '\012' > /tmp/xxx
| 	mv xxx $file
| done

| ------------------------ aii2u (ksh version) ------------------------
| #!/bin/ksh
| 
| # aii2u (ksh version): script to convert files with Apple // newlines
| #  to files with UNIX newlines
| 
| if [ $# = 0 ] ; then
| 	echo "usage: ${0##*/} <filespec>"
| fi
| 
| for file in $*
  ^^^^^^^^^^^^^^

Change to 'for file in $* ; do'

| 	cat $file | tr '\015' '\012' > /tmp/xxx
| 	mv /tmp/xxx $file
| done

| ----------------------- maketext (csh version) ----------------------
| #!/bin/csh
| 
| # maketext (csh version): strip bit seven of every byte in input
| #  file(s). 
| 
| if ( $#argv == 0 ) ; then
| 	echo "usage: $0:t <filespec>"
| 	exit 1
| endif
| 
| foreach file ($*)
| 	(cat $file | tr '[\200-\377]' '[\000-\177]') > /tmp/xxx
                           ^^^           ^^^

Change to 201 and 001, respectively.

| 	mv /tmp/xxx $file
| end
| ----------------------- maketext (ksh version) ----------------------
| #!/bin/ksh
| 
| # maketext (ksh version): strip bit seven of every byte in input
| #  file(s). 
| 
| if [ $# = ] ; then
       ^^^^

Change to '$# = 0'

| 	echo "usage: ${0##*/} <filespec>"
| 	exit 1
| fi
| 
| for file in $*
  ^^^^^^^^^^^^^^

Change to 'for file in $* ; do'

| 	cat $file | tr '[\200-\377]' '[\000-\177]' > /tmp/xxx
                          ^^^           ^^^

Change to 201 and 001, respectively.

| 	mv /tmp/xxx $file
| done
| ---------------------------------------------------------------------

I hope that I have caught all of my mistakes this time.  Sheesh.  :)
-- 
 internet: dockery@griffin.cuc.ab.ca
      -or- sbdocker@acs.ucalgary.ca
      -or- dockery@pro-calgary.cts.com
 pro-line: dockery@pro-calgary