Bash: Getting input from a manifest

Is it possible too have a manifest file with directory strings, fx.

#css

SomeDIR/crap0.css
SomeDIR/crap1.css
SomeDIR/crap2.css

#js

SomeDIR/crap0.js
SomeDIR/crap1.js
SomeDIR/crap2.js 

Lets call this file list.mf

then i have a bash code where i want too use the directory structure defined in list.mf

could be

cat %first entry in list.mf% > crap.txt
cat %second entr in list.mf% >> crap.txt

hoping for you're help, ask further questions if you don't understand my question :=)

/Mathias

Answers


What you are trying to do can be done with a for loop or a simple find, e.g.:

for f in */*css ; do
    cat $f >> OUTPUT.file
done
# SAME
find Somedir/ -iname '*.css' -exec cat \{\} >> OUTPUT.file \;

But if you want to use a config (manifest) file, you can source it in your script, but that way you must use proper (bash) syntax in the config as well e.g. the file list should be in an array, etc, like this "manifest.file" file contents:

#css
export cssfiles=('SomeDIR/crap0.css' 'SomeDIR/crap1.css' 'SomeDIR/crap2.css')
#js
export jsfiles=('SomeDIR/crap0.js' 'SomeDIR/crap1.js' 'SomeDIR/crap2.js'

And in your script:

source /whatever/path/to/manifest.file
# ... then process those variables  
for elem in  ${cssfiles[*]} ; do
    cat $elem >> OUTPUTFILE
done
# and
for elem in  ${jsfiles[*]} ; do
    cat $elem >> ANOTHER_OUTPUTFILE
done

If you need that specific format for your manifest file you can still write some awk||sed||grep scripts to extract the proper lists.

HTH


If your file names really contain numbers, you can just

for i in {0..2} ; do
    grep crap$i'\.' list.mf >> crap.txt
done

If not, I'd use some more advanced language like Perl.


Need Your Help

how can one change the default disk cache behavior in volley?

android android-volley

The service I am using to obtain images, like many such sites does not have a cache control header indicating how long the image should be cached. Volley uses an http cache control header by defaul...

How to trim decimal?

c# decimal

I have a decimal number :

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.