ksh :: want to cut the strings


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh :: want to cut the strings
# 1  
Old 08-20-2008
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.
# 2  
Old 08-20-2008
awk 'BEGIN {FS="/"} {print $1 "," $2}' file
# 3  
Old 08-20-2008
but the output
423562143124/53125351276 is already stored in a variable '$tea'

Is it possible to use the awk command on $tea.

May i know that please.
# 4  
Old 08-20-2008
echo $tea | awk 'BEGIN {FS="/"} {print $1 "," $2}'
# 5  
Old 08-21-2008
I am not getting the values in $1 and $2.

Is there any other way to follow this?
# 6  
Old 08-21-2008
What do you get instead?
# 7  
Old 08-21-2008
I dont get any values for those $1 and $2
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Cut a word between two strings and repeat the same in the entire file

in the below data i need to search for the word typeMismatch and then traverse back to find the filename of that particular mismatch. Like this we have to get all the file names which has error in them. How can i acheive this. I tried use sed or awk but not able to achevie the same. Sample... (2 Replies)
Discussion started by: ATWC
2 Replies

2. Shell Programming and Scripting

Cut the strings from end

could you please help me. I have below autosys jobs 01_enable_input_hol_dtpz1b 01_abc_copy_ld_sat_xxxz1 01_abc_mavcd_yyyyyxxxz1 01_abcdef_oa_xxxxxz1 01_fdgte_symbol_ddddz1 01_fsdfsd_clean_mmmhhhfz1 01_fsdfd_create_mut_marchtz1 I want to remove name after last "_" underscore so that... (6 Replies)
Discussion started by: sdosanjh
6 Replies

3. Shell Programming and Scripting

ksh: how to extract strings from each line based on a condition

Hi , I'm a newbie.Never worked on Unix before. I want a shell script to perform the following: I want to extract strings from each line ,based on the type of line(Nameline,Subline) and output it to another file.Below is a sample format. 2010-12-21 14:00"1"Nameline"Midterm"First Name:Jane ... (4 Replies)
Discussion started by: angie1234
4 Replies

4. Shell Programming and Scripting

KSH Script to watch log files for 2 strings

Hi all, How can I do a ksh script to watch a log file for 2 specific alarms that have one this string : "Connection Error" and the other one: "Failure in sending". I would like to watch for these two alarms in the log and then if each of them repeats for about 30 times to go kill 2 processes. ... (1 Reply)
Discussion started by: Pouchie1
1 Replies

5. Shell Programming and Scripting

How to preserve space while concatenating strings? (KSH)

I have these str1=$(echo "This is string one with spaces \n This is also my sentence 1") When I echo $str1, it displays the new line character properly. Now I have another new variable say str2. I want to concatenate in this way.. str1 + newline character + and then str2. That's I... (3 Replies)
Discussion started by: dahlia84
3 Replies

6. Shell Programming and Scripting

ksh cut out words from string

Hi, I have: export string1=qwerWhatever export string2=qwerWhatever1 export currdir=`pwd` echo $currdir gives back: /dir/dir/Whatever1 I want to take first 4 letters from string1 (in this case: qwer), compare it to string2 (in this case qwerWhatever1) and if string2 has in it... (8 Replies)
Discussion started by: chish
8 Replies

7. 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

8. 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

9. Shell Programming and Scripting

mailx: concatenating strings for message body (KSH)

Hi all, Think this is a pretty simple problem, but I've been thinking about it for a few days. Let's say that I'm going to have to output the contents of a file as the body of a mailx message. I'll probably do this: cat <filename> | mailx <extra commands> However, how do I go about doing... (1 Reply)
Discussion started by: rockysfr
1 Replies

10. Shell Programming and Scripting

ksh - strings

Hi, I want to assign a string to a variable as below a="test " and use 'a' in grep grep $a .. when i tried this it was not taking the blank character in string a. how can represent blank space or blank character please help me thanks venkat (1 Reply)
Discussion started by: itzcoolbuddy
1 Replies
Login or Register to Ask a Question