betweenGo

Save the Output in a Shell Script Variable

by on Dec.14, 2007, under Bash

I was counting how many times a file was referenced by other files. I then wanted to do some processing based on this number.

To do this I saved the output of this count in a variable which I was then able to reference later in the shell script.

num_files=`find . -type f -name '*.html' | xargs grep $img_file | wc -l`

# delete this file if it is not referenced
if [ "0" = $num_files ]
then
  rm $IMAGE_DIR/$img_file
fi


Share

Related posts:

  1. Save the Output in a Shell Script Array
  2. Maven Assembly Convert Shell Scripts to use UNIX LF’s
  3. Shell Tricks
  4. Unable to start Cygwin shell from Windows command prompt
  5. Shell Scripts with Windows LF’s Fail in Latest Cygwin


Leave a Reply

 

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!