07-31-2009
Bash: Reading out rows of a file into a dynamic array and check first literal
Hello,
i have a file "Movie.ini" looking e.g. like follows
* MOVIE A
bla bla
MOVIE B
blubb blubb
MOVIE C
I'd like to read the file "Movie.ini" with cat and grep and check whether it includes the string MOVIE only with a '*' at the beginnig.
By doing
"cat Movie.ini| grep MOVIE >> tmp_MOVIE "
all rows containing MOVIE should be saved in a tempfile
* MOVIE A
MOVIE B
MOVIE C
I have following problem, since I just know a bit ksh but not bsh:
1. How can I read out the rows of the file "tmp_MOVIE" in a VARIABLE long / dynamic allocated array? (Since there is NOT a fix number of rows containing the string MOVIE - it can be 3, 5 or e.g. 20)
2. How can I check the first literal of an array-element whether it is a '*'?
Thanks a lot for any helpful answer
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
A few days ago I created my amateur version of the cat function in bash. Here is what I've done:
#!/bin/bash
#This is mycat. Similar to cat.
#For detailed information use path/to/mycat.sh -h option
arguments=$#
if ] #in case of standard input
then
while ]
do
read input... (4 Replies)
Discussion started by: sanchopansa
4 Replies
2. Shell Programming and Scripting
Hi Everyone,
I have a file: a.txt
a,b,c,d,6,6,6
1,2,3,d,6,6,6
4,5,6,6,6,6,6
#!/usr/bin/perl
use warnings;
use strict;
my @array = ();
### Load file into array
for my $i (split '\n', `cat /tmp/a.txt`) {
push @array, ;
}
It works. But my a.txt have 1million lines, and... (2 Replies)
Discussion started by: jimmy_y
2 Replies
3. Shell Programming and Scripting
I am not sure if using cat -n is the most efficient way to split a file into multiple files, one file per line in the source file.
I thought using cat -n would make it easy to process the file because it produces an output that numbers each line that I could then grep for with the regex "^ *$i".... (3 Replies)
Discussion started by: kapu
3 Replies
4. Shell Programming and Scripting
Hello,
I'm new in Shell scripting but i should write a script, which inserts the license header out of a txt-File into the files in our Projekt. For the Java classes it runs without Problems but for XML files not. At xml-files i have to put the license Header after the xml-Header (?xml... (2 Replies)
Discussion started by: PhoenixONE
2 Replies
5. Shell Programming and Scripting
Hallo,
ich habe mir mit meinen dürftigen Programmierkenntnissen ein Script zusammengebastelt über das ich in einem bestimmten Odner mit AWK alle Dateien eines Verzeichnis durchsuche und bestimmte Bezeichungen aller Dateien ändern kann.
Es funktioniert auch soweit, nur hätte ich gerne auch die... (1 Reply)
Discussion started by: ruffi
1 Replies
6. Solaris
Hallo :-)
Ich habe da ein Problem beim Zugriff von Solaris mittels rdesktop auf eine TS Farm unter W2K8R2 mit NLB und Session Broker.
Ich bekomme folgende Fehlermeldung:
user@sunray2xxx /h/user/Desktop 150 > rdesktop terminalserver
WARNING: Remote desktop does not support colour... (1 Reply)
Discussion started by: chrischi1978
1 Replies
7. Shell Programming and Scripting
I have figured out how to grep the file like this:
echo `grep $(date +'%Y-%m-%d') Cos-01.csv | cut -d',' -f1`
The above line does echo the correct information from the lines in which my search criteria is found.
Now I am trying to get that information (Yes, just one column of every line) into... (6 Replies)
Discussion started by: TwelveDays
6 Replies
8. Shell Programming and Scripting
Hi,
Normally, I would do
cat /etc/oratab | grep -v "^#" | grep -v "^*" > /tmp/oratab.00
while read line
do
echo $line
done < /tmp/oratab.00I want to know whether it is possible to use an array instead of re-directing it to file?
As a test, I did something like below:
#!/bin/ksh
... (6 Replies)
Discussion started by: newbie_01
6 Replies
9. Shell Programming and Scripting
Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help.
pesudo code
if == ENDSINFIVEINTS ]]; then
do... (4 Replies)
Discussion started by: briandanielz
4 Replies
10. Shell Programming and Scripting
hello,
i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case
i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N.
for case 1, I want to stretch N to fit M
arrayHuge
H = (... (2 Replies)
Discussion started by: f77hack
2 Replies
SWF(3pm) User Contributed Perl Documentation SWF(3pm)
NAME
SWF - an autoloadable interface module for Ming - a library for generating ShockWave Flash format movies.
SYNOPSIS
# Don't import other modules
use SWF;
# import all SWF modules
use SWF qw(:ALL);
# import SWF::Shape and SWF::Movie only.
use SWF qw(Shape Movie);
DESCRIPTION
By default, SWF doesn't import other SWF classes. You may, however, instruct SWF to import all modules by using the following syntax:
use SWF qw(:ALL);
METHODS
SWF::setScale($scale);
Sets scale to $scale.
SWF::getScale();
Get the current scale. 20 means 20 twips (1/20 of a pixel) and is the default value.
SWF::setVersion($version);
Sets SWF version for the header of flashfiles. Choose a value between 4 and 7 for your flashmovies. If you are unsure take 5.
SWF::setCubicThreshold($num)
Sets the threshold error for drawing cubic beziers. Lower is more accurate, hence larger file size.
SWF::setSWFCompression($level);
Set output compression level. Returns previous value. $level is integer between 0 and 9. Note: This function is called automatic too
by $movie->save($filename[,$level]) and $movie->output([$level]) if the optional parameter $level is given.
SWF::useConstants($flags);
?
AUTHOR
Soheil Seyfaie (soheil at users.sourceforge.net).
SEE ALSO
SWF.pm related modules: SWF::Action, SWF::Bitmap, SWF::Button, SWF::Constants, SWF::DisplayItem, SWF::Fill, SWF::Font, SWF::Gradient,
SWF::Morph, SWF::Movie, SWF::MovieClip, SWF::PrebuiltClip, SWF::Shape, SWF::Sound, SWF::TextField, SWF::Text, SWF::VideoStream, SWF::Sprite
other projects: SWF::Builder - a pure perl alternative to Ming
perl v5.14.2 2012-03-05 SWF(3pm)