multiple cuts syntax problem


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers multiple cuts syntax problem
# 8  
Old 10-31-2005
Hi,

Sorry to take so long to get back to you, I am finally getting round to implementing the code as you suggested, but right off the bat I get the following message

UX:sh (./Iptestger): ERROR: Bad substitution

code

#! /bin/sh
while read line
do
col1=${line:0:1}
echo $col1
done < WAITING
# 9  
Old 10-31-2005
I dont see any error in that code. Unless WAITING is not a file. You can not put in a variable in that place like that.

Edit. The shell is sh. So it should work. ksh does not have the same construct.

vino
# 10  
Old 10-31-2005
/bin/sh on most (all?) linux distributions is a link to bash.

If you're running on just about any other UNIX type system then sh will not have the functionality described. You need to use bash itself (instead of sh).
# 11  
Old 10-31-2005
Thanks,


I tried the below code in bash, perhaps I don't have bash on my system as I get the following error now

# ls -lt Iptestger WAITING
-rwx------ 1 root other 2118 Oct 31 12:15 Iptestger
-rw-r--r-- 1 root other 1180 Oct 31 10:53 WAITING

# ./Iptestger
UX:sh: ERROR: ./Iptestger: Not found

#! /bin/bash
while read line
do
col1=${line:0:1}
done < WAITING

# head -2 WAITING
IG405HC7 1342567SG002534181190725G52 1HP G52202 ADCR 31100511310797 C292 011198
IG405HCB 4558796SG003527361070252G52 3AW G52378 LA CHECK CYSTOSCOPY 31100572040301 M459

Last edited by Gerry405; 10-31-2005 at 08:36 AM..
# 12  
Old 10-31-2005
You can check in /usr/local/bin to see if bash is there (you'll have to change the #!/bin/bash to #!/usr/local/bin/bash of course).

If bash is not present on your system then you'll need to get hold of a copy or do it some other way
# 13  
Old 10-31-2005
I just have these

# ls -lt /usr/bin/*sh*
-rwxrwxrwx 1 root other 271 Nov 30 2001 /usr/bin/shtty
lrwxrwxrwx 1 root other 5 Oct 19 1999 /usr/bin/rsh -> remsh
lrwxrwxrwx 1 bin bin 5 Oct 19 1999 /usr/bin/rksh -> ./ksh
lrwxrwxrwx 1 bin bin 13 Oct 19 1999 /usr/bin/restsh -> ../../sbin/sh
lrwxrwxrwx 1 bin bin 13 Oct 19 1999 /usr/bin/jsh -> ../../sbin/sh
lrwxrwxrwx 1 bin bin 13 Oct 19 1999 /usr/bin/sh -> ../../sbin/sh
-rwsr-xr-x 1 root bin 25696 Jun 4 1999 /usr/bin/remsh
-rwxr-xr-x 1 bin bin 80040 Jun 4 1999 /usr/bin/rshd
-rwxr-xr-x 1 bin bin 175948 Jun 4 1999 /usr/bin/ksh
-rwxr-xr-x 1 bin bin 7369 Jun 4 1999 /usr/bin/admrshell
-rwsr-xr-x 1 root sys 38592 Feb 26 1998 /usr/bin/shl
-r-xr-xr-x 1 bin bin 223120 Apr 2 1997 /usr/bin/csh
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Multiple DNS forwarders and syntax question.

Hey Guy's, Is there a limit on the number of forwards that can be used or the syntax and spaces? I noticed I have to put spaces between ; and the IP for at least the first one, then space at the end to work and the rest don't work at all no matter what I try. forward first; ... (1 Reply)
Discussion started by: Devyn
1 Replies

2. Shell Programming and Scripting

Python script cuts off early

I wasn't sure if this should go in the networking board or not, since I am trying to log into routers, however I don't think my script issues have anything to do with the routers themselves.... I am trying to write a script that will log into various routers we have on the network and determine... (2 Replies)
Discussion started by: ippy98
2 Replies

3. Shell Programming and Scripting

Problem with if-else syntax

I'm calling the following if-else from nawk. But I keep getting an error at the "else". I've tried putting more brackets and ; but still I get complaints about the "else". Any ideas ? Thanks, wbrunc BEGIN { FS = "," ; OFS = "," } { if ( $8 ~ /A/ && $9 == B ) $1="4/29/2013" ; $2="J.Doe"... (2 Replies)
Discussion started by: wbrunc
2 Replies

4. Shell Programming and Scripting

Awk if-else syntax with multiple columns

I can't seem to get this to work. I can reformat the date field if it's the first field (and only field) in the file: However, I get a syntax error when the date field is the second field (or has any other columns following): I can use a ";" but then it puts each column on separate... (8 Replies)
Discussion started by: giannicello
8 Replies

5. Shell Programming and Scripting

Multiple echos and cuts too slow

Hi guys, hopefully this hasn't been asked before - couldn't see the question anywhere. I have a large number of timestamps (hh-mm-ss-millisecond) that I need to find the difference between e.g.: 14-11-07-513 14-11-07-644 Now the script that I have just knocked up is horrifically slow,... (4 Replies)
Discussion started by: dlam
4 Replies

6. Shell Programming and Scripting

How do I write multiple variable syntax?

I am trying to write a script that will do a sql statement. But in the sql I will have a list (1,2,3,4). How would I go about asking for the input from the user running the script, and then transferring that back into the list as say ($var1,$var2,$var3)? It would be somewhat like this: ... (1 Reply)
Discussion started by: Captain
1 Replies

7. Solaris

Custom short cuts not working on JDS

Hello, I had created a shortcut to open up a gnome-terminal by pressing <Alt>m. This worked fine, until I logged out and logged back in. gnome-terminal no longer opens. However, the process is created, as evidenced by the gnome-terminal showing up on my process list. I've created and deleted... (1 Reply)
Discussion started by: cooldude
1 Replies

8. Shell Programming and Scripting

syntax problem

Dear friends, I am writing shell script in csh . i want to make arthimatic operation in csh. i wrote sysntax like this. set val = 230 set tmp = `0.1 * $val + 300` echo $tmp but it is not working . anyone please give me syntax. (3 Replies)
Discussion started by: rajan_ka1
3 Replies

9. Shell Programming and Scripting

syntax problem

dear friends, I have a large size file containg two fields data like this *** **** 122 222 ***** ***** ***** ***** 232 233 i have file like this. i want to remove blank lines from file . i think awk is servive this problem i wrote a awk command but the error is... (3 Replies)
Discussion started by: rajan_ka1
3 Replies
Login or Register to Ask a Question