I can't understand sed error output.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I can't understand sed error output.
# 1  
Old 10-12-2010
I can't understand sed error output.

Hey forum,

I have a problem with a script what used to work, but suddenly is not working anymore. I have been trying different things for an hour now and I give up Smilie .


Code:
#!/bin/sh

asukoht=`pwd`
template=$1
for values in {2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0}; do
    set $values
    X=$1
    mkdir "$X"
    sed "s/X\$/$X/" "$template" > ./$X/"coord"
    cd ./$X
#    sh ../define.sh
#    sh ../cosmoprep.sh
    cd $asukoht
done

The template file is in the same directory as the script.

Code:
[TM510] mario8@fermi84 (konf1karbo) >ls
alg-coord~  coord.xyz  cosmoprep.sh  defineerija_lahus.sh  defineerija_lahus.sh~  define.sh  template  template~

And the error output is:

Code:
[TM510] mario8@fermi84 (konf1karbo) >sh defineerija_lahus.sh
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory
sed: can't read : No such file or directory

I don't understand, because everything is in order imo.

Thank you in advance Smilie .
# 2  
Old 10-12-2010
You want to vary a value "$values" in the for-loop. The variable "$values" is never used any further - are you sure this is what you want?

Presumably the line X=$1 should read X=$values, but this would raise the question why to bother with a variable "X" when you could use the variable "values" equally.

I hope this helps.

bakunin

PS: it often pays to add a few lines printing some variables contents in a loop to understand what goes wrong and how.
# 3  
Old 10-12-2010
Hi,

I think the problem is the '$template' variable. It has no value and 'sed' expects it. Here:
Code:
template=$1
...
sed "s/X\$/$X/" "$template" > ./$X/"coord"

I hope it helps.

Regards,
# 4  
Old 10-12-2010
Quote:
Originally Posted by bakunin
You want to vary a value "$values" in the for-loop. The variable "$values" is never used any further - are you sure this is what you want?

Presumably the line X=$1 should read X=$values, but this would raise the question why to bother with a variable "X" when you could use the variable "values" equally.

I hope this helps.

bakunin
I need to create multiple files with different inputs (the template file).

Anyway, thanks for your help. I took the
Code:
asukoht=`pwd`

command away from the script and it started working Smilie . Thanks for your anwsers Smilie .
# 5  
Old 10-12-2010
You could use a default value if no parameter like
Code:
template=${1:-template}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can't understand script output

New to korn shel1 and having an issue. The following is suppose to read the parameter values from files in a source directory and then pass them on to a log file in a different directory, The ArchiveTracker scripts is suppose to call the parameterreader script to exact the parameter values and... (3 Replies)
Discussion started by: bayouprophet
3 Replies

2. Shell Programming and Scripting

understand sed

cat teledir.txt jai sharma 25853670 chanchal singhvi 9831545629 anil aggarwal 9830263298 shyam saksena 23217847 lalit chowdury 26688726 If i use the below command , it is giving me the output with "," in between two name. how ? and also i would like to know the reason for the space used in... (1 Reply)
Discussion started by: Antony Ankrose
1 Replies

3. UNIX for Advanced & Expert Users

unable to understand the output of TRUSS command

Hi, I am trying to set ulimit for soft stack unlimited, but this is not taking effect, after tracing the ulimit -a unlimited command, the below output was generated, which i am unable to comprehend. Could any one help me with this? prcbap1-r10prod: truss -d ulimit -s unlimited Tue Dec 30... (2 Replies)
Discussion started by: NasirAbbasi
2 Replies

4. Shell Programming and Scripting

I am learning regular expression in sed,Please help me understand the use curly bracket in sed,

I am learning SED and just following the shell scripting book, i have trouble understanding the grep and sed statement, Question : 1 __________ /opt/oracle/work/antony>cat teledir.txt jai sharma 25853670 chanchal singhvi 9831545629 anil aggarwal 9830263298 shyam saksena 23217847 lalit... (7 Replies)
Discussion started by: Antony Ankrose
7 Replies

5. Shell Programming and Scripting

Do not understand grep output

In my directory I have two files and one subdirectory. When I run ls -l |grep -v ^d I get the following output: total 8 -rwxrwxrwx 1 qms qms 254 Oct 3 16:00 file1.txt -rwxrwxrwx 1 qms qms 7167 Oct 11 15:46 file2.txt Can you explain what is total 8 if the number of files is 2 and is... (3 Replies)
Discussion started by: rdogadin
3 Replies

6. UNIX for Dummies Questions & Answers

Not able to understand this output

I am hitting this command: dvlna021-(/cm/ims/dev/gds-scheduler/10/app/Software/active/Soft/conf)->ls -lrt gds_userenv_* This is the output lrwxrwxrwx 1 aimse was 65 Jul 31 12:56 gds_userenv_scheduler_2.ksh -> /cm/ims/dev/gds-scheduler/10/app/conf/gds_userenv_scheduler_2.ksh ... (2 Replies)
Discussion started by: Nsharma3006
2 Replies

7. UNIX for Dummies Questions & Answers

Not able to understand the output of w command

I have taken putty session of a server from two separate machines namely HOST1(3 sessions) and HOST2(1 Session) . However w command says there are 5 users Confused over the output any clue will be appreciated. # w 09:29:36 up 34 days, 15:48, 5 users, load average: 0.62, 4.33, 8.16 USER ... (3 Replies)
Discussion started by: pinga123
3 Replies

8. UNIX for Dummies Questions & Answers

Unable to understand ps output.

I m executing ps command and sorting it according to memory usage. Please find the output of the command. # ps aux --sort pmem USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 2060 624 ? Ss 01:54 0:00 init root 2 0.0... (1 Reply)
Discussion started by: pinga123
1 Replies

9. Shell Programming and Scripting

Need to understand the output of last command

root@desktop:~# last reboot | head -1 reboot system boot 2.6.31-17-generi Tue Jan 26 12:05 - 13:52 (01:46) What does the last two fields(12:05 - 13:52 (01:46)) of the output mean? (2 Replies)
Discussion started by: proactiveaditya
2 Replies

10. Shell Programming and Scripting

trying to understand what sed is doing?

Can someone help me understand why sed '/host/ s/$/QQQ/g' junk is taking the file 'junk' which is this: host Example_1 filename-"gfnwd.cfg"; hardware-ethernet-00:13:11:fd:7a:88; fixed-address-10.10.6.19; } host Example_2 filename-"gfnwd_280.cfg";... (2 Replies)
Discussion started by: TheBigAmbulance
2 Replies
Login or Register to Ask a Question