Steve,
Gotta see an awk in there too.. ;-)
For the experienced user:

#!/bin/sh
# tabs.awk
# Usage: cat Some_File | tabs.awk
# or cat Some_File | tabs.awk > New_File
awk '{gsub("\t","|",$0); print $0}'
#end tabs.awk

And for the inexperience users:

#!/bin/sh
# tabs.sh to change TABS to | (pipes)
# Usage: tabs.sh new old or 
# tabs.sh will send output to stdout
#
old=$1
new=$2

case "${old}" in
  "") echo "USAGE: `basename $0` old_file new_file" ; exit ;;
  *) if [ -s "${old}" ]
     then
       /bin/true
     else
       echo "\"${old}\" does not exist. Please check filename and try again."
       exit
     fi
   ;;
esac

FILE=`cat "${old}" | awk '
{
  gsub("\t","|",$0)
  print $0
}'`

case "${new}" in
  "") echo "${FILE}" ;;
  *) if [ -s "${new}" ]
     then
       echo "\"${new}\" exists! Overwrite ? <y> or <n>"
       read answer
       case "${answer}" in
         y|Y) echo "${FILE}" > "${new}" 
              echo "New file created: ${new}"
              exit
         ;;
         n|N) echo "Exiting... No work done..." ; exit ;;
         *) echo "Invalid Option. y or n Only. Exiting..." ; exit ;;
       esac
     else
       echo "${FILE}" > "${new}"
       echo "New file created: ${new}"
       exit
     fi
  ;;
esac
#end tabs.sh

Have fun,
--
Rick L. Mantooth
[EMAIL PROTECTED]
Why is "abbreviation" such a long word?

On Wed, 1 Dec 1999, Steve Lee wrote:

> can someone show me a quick
> script to insert | in place of tabs
> 
> for example: i have 40 lines with many columns
> delimited by tabs that require it to be delimited 
> by | but in excel i can't do that. so 
> i would export the excel file as a text delimited by
> tabs than would like a script to insert | in place of
> the tab.
> 
> please help.
> 
> this would save so much time for me.
> 
> 
> -- 
> To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
> as the Subject.
> 
> 


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to