Search Results

Search: Posts Made By: josegr
4,590
Posted By josegr
floating point not recognized by printf in bash
Dear all,

I have the following question. Let's say that I have the following script

#!/bin/bash
value=0.4987865
a=` printf "%6.2f" $value `
b=`echo $value + $value | bc -l`
echo $a
echo...
1,555
Posted By josegr
Great!, it works, thanks a lot J
Great!, it works, thanks a lot

J
1,555
Posted By josegr
Passing screen value to a program
Hi all,

I have the following question. Apparently not very difficult, but I'm not any expert.
I have a program, let's say program.x, and a bash script that execute it, let's say program.sh....
3,964
Posted By josegr
Thanks for the reply, but actually n0 can take...
Thanks for the reply, but actually n0 can take any value, it is not 7.00 necessarily. I've solved it concatenating a second cut command which defines another delimiter " ":

> n0=` grep "n0" $bsim...
3,964
Posted By josegr
Find a string and extract a value from a file
I have a file where a line has the following form:

n0=7.00 !Central density [10**19 m-3]

and I want to extract the value 7.00. I used to do this with the order below, which finds the...
2,317
Posted By josegr
Right, I had not realized!. Thanks
Right, I had not realized!. Thanks
2,317
Posted By josegr
cat > variable + format
I wanted to store a value read from a file in a variable with a given format. I was doing the first step as follows :

it0="$(cat ./myfile)"

I thought the second step would work as: it0= `...
1,346
Posted By josegr
Thanks!. I was transfering the content to a...
Thanks!. I was transfering the content to a tempfile. With -i option perfect. Thanks again
1,346
Posted By josegr
Great!. It works. But, how can I do to avoid...
Great!. It works. But, how can I do to avoid screen output?
1,346
Posted By josegr
replace a line
I wanted to replace a line from a file, the 8th for example, independently of what it's written in a line. Thanks
1,609
Posted By josegr
Thanks a lot Jean-Pierre. Much better!
Thanks a lot Jean-Pierre. Much better!
1,609
Posted By josegr
well, I found out it is just if [ "$1" = ""...
well, I found out it is just

if [ "$1" = "" ]
then
echo 'esto es 2'
fi
1,609
Posted By josegr
empty option output error
I have a script (multirun.sh) which launches the program bsim_em.x or bsim_es.x depending on the value entered from the screen:

> multirun.sh 1 (executes bsim_em.x)
> multirun.sh 2 (executes...
3,296
Posted By josegr
Yes that is. With for line in $(ls); do head...
Yes that is. With

for line in $(ls); do head -1 $line >> myfile; done

worked as well if I had the files, whose first lines I want to put together, in the same directory, but it is not like...
3,296
Posted By josegr
It works!, thanks a lot
It works!, thanks a lot
3,296
Posted By josegr
head command with more than one file
Hi, I have the following problem. I have files with one column of data (let's say file1.dat, file2.dat...file6.dat), and I would like to record the first value of the column of each file into another...
11,728
Posted By josegr
Thanks a lot! the second way works perfectly!!
Thanks a lot! the second way works perfectly!!
11,728
Posted By josegr
echo + bc + format
Hi,

I was trying to define a variable as a result of an operation,

b=` echo $a+1 | bc -l`

with a specific format (5 digits integer completing with zeros, 00025, for example)

c=` printf...
2,005
Posted By josegr
Got it!, I had not understood the delimiters...
Got it!, I had not understood the delimiters politics properly,

var=` grep "Total Transmission pow." file.dat | cut -d "." -f2,3`

thanks again!
2,005
Posted By josegr
Thanks for the answer, I've tested the first one...
Thanks for the answer, I've tested the first one and it works, thanks a lot, but for the real case I'm working with does not (the first message file composition was an example that I thought was...
2,005
Posted By josegr
read a value from a string/line
I have a file that contains the something like this

a=15
b=21.5
c=544
and so on

the question is how could I find the line that contains the value of c and store its value on a variable in...
44,363
Posted By josegr
thanks: printf "%06d\n" can it be done with...
thanks:
printf "%06d\n"
can it be done with echo as well?
44,363
Posted By josegr
Number/string format in bash
I would like to change the format of an integer type number adding zeros to the left of it in a script in bash. For example

number=1
echo $number

00001

Thanks
Showing results 1 to 23 of 23

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