You are not logged in.
Pages: 1
I want my program to accept two arguments, So im wondering how to do this.
#!/bin/bash
for FILE in "" #<-- need a for loop or some way to accept up to 2 arguments.
do
while read MyLine
do
if [[ "$MyLine" =~ "sed -n '/printregex/,/to this regex/{/but not this
regex/d;p}' | sed -n '/---/,+3!p' | sed -n '/#/!p' | sed 's/^[ ]*//'
| sed -e s/[^:]*://" ]]; then
tmp=$(echo $MyLine)
fi
while read MyLine2
do
if [[ "$MyLine2" =~ "sed -n '/regex/,/to regex/{/but not including this regex/d;p}'
| sed - n '/#/!p | sed -e s/[^:]*// | sed /---------------/,+10d ]]; then
tmp2=$(echo $MyLine)
fi
done > $FILE
done > $FILE
done
I think the sed regex's are fine. This is not my exact script, but the one im executing yeilds a blank line, i think i might be outputting something wrong..
Offline
Look into using getopt. Also the case statement.
[git] | [AURpkgs] | [arch-games]
Offline
Well i might want to open the file with the if statements, and then use, Var1=$(echo $MyLine | sed - n ... )
Last edited by oxoxo (2008-12-04 03:49:38)
Offline
to read a line in my file:
if [[ "$line" =~ ^regex ]];
Which works...So i'll try to read the file from that regex to end..so..
if [[ "$line" =~ /regex/,$p ]];
And nothing! ...
I can do a:
myFile.txt | sed -n '/regex/,$p'
wow..
Offline
:mad:ok supply the script with an existing file.
#!/bin/bash
FILE="$1"
echo "You Entered $FILE"
if [ -f $FILE ]; then
tmp=$(cat $FILE)
MyVar=$(echo $tmp | sed -n '/regex/,/regex/{/regularx/d;p\}' |\
sed -n '/---/,+3!p' | sed -n '/#/!p' | sed 's/^[ ]*//' |\
sed -e s/[^:]*://)
echo "$MyVar"
fi
save the contents of that file in a tmp varaible. echo tmp and change the file with sed and store that into a myVar varaible. Echo myVar varaible..
why isnt that working?
wow..
So i try one by one..and stilll nothing...
# $tmp has the contents of the file
# This is all outside of: if [ -f $FILE ]; then tmp=(cat $FILE)
wow=$(echo $tmp | sed -n '/regex/,/regex/{/regex/d;p}')
wow2=$(echo $wow | sed -n '/---/,+3!p' )
wow3=$(echo $wow2 | sed -n '/#/!p' )
wow4=$(echo $wow3 | sed 's/^[ ]*//' )
wow5=$(echo $wow4 | sed -e s/[^:]*:// )
echo "$wow5"
Last edited by oxoxo (2008-12-04 08:15:44)
Offline
Pages: 1