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

Re: Bash scripting



Jeff Elkins <jeffelkins@earthlink.net> writes:

> ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e 
> s/arm.*/arm/ -e s/sa110/arm/
>
> I'm working on polishing my meagre shell scripting skills and would
> appreciate some feedback on the line above, quoted from the kernel Makefile.
>
> 1. How would you use this in a straight bash script so it returned a value
> containing the boxes architecture?

The contents of the $(shell ...) Make fragment should be a valid shell
command.

> 2. As far as comparisons go, if I wanted to determine if a string contained
> ".xyz" or ".abc" would that be a variant of the fragment above?

Two somewhat common ways:

  uname -m | grep i.86 > /dev/null && echo x86

  case `uname -m` in
    i?86) echo x86 ;;
  esac


-- 
David Maze         dmaze@debian.org      http://people.debian.org/~dmaze/
"Theoretical politics is interesting.  Politicking should be illegal."
	-- Abra Mitchell



Reply to: