Search Results

Search: Posts Made By: newbreed1
5,598
Posted By newbreed1
Array as parameter
Can I pass and array as a function paramter?

#!/bin/bash

a1[1]=one
a1[2]=two
a2[1]=one
a2[2]=two

function f1()
{
array1copy=( ${1[@]} )
array2copy=( ${2[@]} )
echo...
5,875
Posted By newbreed1
line by line file comparison
I have sifted through many past posts but have not found a good solution.
I have a 2 files that hold a filename and its cksum value like this:

FILE1 contents:
45435347589 filename1

FILE1 is...
6,118
Posted By newbreed1
Well, I've tried all day and this is what I...
Well, I've tried all day and this is what I finally came up with:

prev=`expr "$(sed -n '/ET_SCCSREL=/p' $FILE)" : '.*\(....\)'`
new=$(echo "scale=1; $prev + 1.0" | bc )
nawk -v prev=$prev -v...
6,118
Posted By newbreed1
It appears to be the '.' that is giving me...
It appears to be the '.' that is giving me problems.

File Contents:
SCCS=33.0

The awk command:
prev=`awk -F"=" '{ print $2 }' $FILE`
returns: 33.0

when I tried to pass this to sed it...
6,118
Posted By newbreed1
Man... this stinks. I am on SunOS 5.8 I can't...
Man... this stinks.
I am on SunOS 5.8
I can't figure out why this isn't working. When I do this from the command line:
prev=33.0; new=34.0; sed s/$prev/$new/g $FILE

it works fine. But within...
6,118
Posted By newbreed1
Like this? prev=$(awk -F"=" '{ print $2 }'...
Like this?
prev=$(awk -F"=" '{ print $2 }' $FILE)
new=$(echo "scale=1; $prev * 10" | bc )
echo $prev
echo $new
sed "s/$prev/$new/g" $FILE

I receive this:
33.0
330.0
sed: command garbled:...
6,118
Posted By newbreed1
I receive the same results from: sed ...
I receive the same results from:
sed "s#$prev#$sccs#g" $FILE

I am in bash. I am not sure how to tell what version I am using.
6,118
Posted By newbreed1
Unfortunately yes. Line from FILE: ...
Unfortunately yes.

Line from FILE:
SCCS=33.0

With this:
prev=$(awk -F"=" '{ print $2 }' $FILE)
new=$(echo "scale=1; $prev * 10" | bc )
sed "s/$prev/$new/g" $FILE
...
6,118
Posted By newbreed1
I apologize about the mis-code. True the awk...
I apologize about the mis-code. True the awk does not produce these specific values. The values will change so I wanted to pass them to the sed script as variables. $prev will be what ever is...
6,118
Posted By newbreed1
sed substitute situation
I am having a problem executing a sed substitute in a file. I have tried alot of different things I found in previous posts, however non seem to work.
I want to substitute this in $FILE:...
Showing results 1 to 10 of 10

 
All times are GMT -4. The time now is 07:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy