ksh cut out words from string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh cut out words from string
# 8  
Old 07-07-2010
daPeach,
Which shell r u using?

Code:
>cat 1
#!/usr/bin/ksh

string1=qwerWhatever
s1f4=${string1:0:4}
echo $s1f4

>
>1
1[4]: s1f4=${string1:0:4}: bad substitution

# 9  
Old 07-07-2010
I'm on ksh93, and bash. It also works with Bourne shell.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to filter string between specific string in ksh

My argument has data as below. 10.9.9.85 -rwxr-xr-x user1 2019-10-15 17:40 /app/scripts/testingscr5.scr 127869538 -rwxr-xr-x user1 2019-10-15 17:40 /app/scripts/testingscr56scr 127869538 ....... (note all these between lines will start with hyphen '-' ) -rwxr-xr-x user1 2019-10-15 17:40... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. Shell Programming and Scripting

Grep only words containing specific string

Hello, I have two files. All urls are space seperated. source http://xx.yy.zz http://df.ss.sd.xz http://09.09.090.01 http://11.22.33 http://canada.xx.yy http://01.02.03.04 http://33.44.55 http://98.87.76.65 http://russia.xx.zz http://aa.tt.xx.zz http://1w.2e.3r.4t http://china.rr.tt ... (4 Replies)
Discussion started by: baris35
4 Replies

3. Shell Programming and Scripting

Search string within a file and list common words from the line having the search string

Hi, Need your help for this scripting issue I have. I am not really good at this, so seeking your help. I have a file looking similar to this: Hello, i am human and name=ABCD. How are you? Hello, i am human and name=PQRS. I am good. Hello, i am human and name=ABCD. Good bye. Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies

4. UNIX for Advanced & Expert Users

cut words based on the word count of a line

I would like to cut words based on the word count of a line. This over here inspired me with some ideas but I wasn't able to get what I needed. https://www.unix.com/shell-programming-scripting/105841-count-words-each-line-file-using-xargs.html If the line has 6 words I would like to use this.... (8 Replies)
Discussion started by: cokedude
8 Replies

5. Shell Programming and Scripting

ksh + isql => output cut at 2 GB

Using a ksh script, I'm dumping the data from our sybase database into an output file. This output file is for what ever reason cut at 2GB. There is enough space on the unix machine and as there is no error message is received I have no clue to start looking for a solution. #!... (1 Reply)
Discussion started by: bereman
1 Replies

6. Shell Programming and Scripting

splitting words from a string

Hi, I have a string like this in a file, I want to retrive the words separated by comma's in 3 variables. like How do i get that.plz advice (2 Replies)
Discussion started by: suresh_kb211
2 Replies

7. Shell Programming and Scripting

Need to cut filename in LINUX ksh

Hi, I need to cut filename in Linux ksh. for example file name is c_xxxx_cp_200908175035.zip. I need to get variable with only c_xxxx_cp value. (10 Replies)
Discussion started by: juliyp
10 Replies

8. Shell Programming and Scripting

ksh :: want to cut the strings

I have contents like 423562143124/53125351276 sdgas/347236 sjhdk;ls'ald/y62783612763 I need a command that would make the string before / and after / as separate output as (A should contain 423562143124 )and B should contain 53125351276). I tried but in vain. Please help. (19 Replies)
Discussion started by: rollthecoin
19 Replies

9. Shell Programming and Scripting

FInd the String between Two words

Hi I would like know how can write a script for find a string between two words. My input like this: a1 IN a1a1a1a1a1a1 OUT b1 IN b1b1b1b1b1b1 OUT c1 IN c1c1c1c1c1c1 OUT . . . now my out put like: a1a1a1a1a1a1 b1b1b1b1b1b1 c1c1c1c1c1c1 please help on this. (6 Replies)
Discussion started by: koti_rama
6 Replies

10. Shell Programming and Scripting

read string, check string length and cut

Hello All, Plz help me with: I have a csv file with data separated by ',' and optionally enclosed by "". I want to check each of these values to see if they exceed the specified string length, and if they do I want to cut just that value to the max length allowed and keep the csv format as it... (9 Replies)
Discussion started by: ozzy80
9 Replies
Login or Register to Ask a Question