(Bash scripting)setting variables from the shell
I want to do this (dont give me other ways of doing this specific task since I want to make an abstract to apply in other situations) # locate netscape (pipe) grep xpm (pipe) cp stdout /opt/kde/share/icons Now how do I assign: "locate netscape (pipe) grep xpm" to be variable $1 and then how do I manage to make cp copy $1 ? What about more than a variable? Thanks! Raul
On Sun, Dec 02, 2001 at 12:47:53AM -0300, Raúl Gutiérrez Segalés wrote:
I want to do this (dont give me other ways of doing this specific task since I want to make an abstract to apply in other situations)
# locate netscape (pipe) grep xpm (pipe) cp stdout /opt/kde/share/icons
Now how do I assign:
"locate netscape (pipe) grep xpm"
to be variable $1 and then how do I manage to make cp copy $1 ?
What about more than a variable?
Here are a couple of things to try: 1) cp `locate netscape | grep xpm` /opt/kde/share/icons This is pretty straightforward but I think it can fail if the number of files found causes the cp command to exceed a maximum length (4096 characters?). 2) for f in `locate netscape | grep xpm` ; do cp $f /opt/kde/share/icons; done This is more general and doesn't push the command line limitations. Note that the quotes in both of the above are actually back-quotes. -- ____________________________________________________________________ Robert Paulsen paulsen@texas.net
participants (2)
-
Raúl Gutiérrez Segalés
-
Robert C. Paulsen Jr.