String manipulation in TCL


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting String manipulation in TCL
# 1  
Old 03-07-2008
String manipulation in TCL

Suppose pwd=/home/user/work/wip1

How to output the "pwd string" into 5 chunks?

/home/user/work/wip1
/home/user/work
/home/user
/home
/

Smilie
# 2  
Old 07-15-2008
I'm new to tcl, here's how I did it.


set pwd [pwd]

set y [split $pwd "/"]

puts $pwd
puts "/[lindex $y 1]/[lindex $y 2]/[lindex $y 3]"
puts "/[lindex $y 1]/[lindex $y 2]"
puts "/[lindex $y 1]"
puts "/"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

TCL - quotes inside a string assigned to a var

I know that set line "This is a line." puts whats between " inside the var line. But How do I do the same for set line "This is a line "with quotations" inside the string." (2 Replies)
Discussion started by: popeye
2 Replies

2. Shell Programming and Scripting

TCL expect out string with multiple lines

Hello, I will be sending this command to a specific COMID: exp_send-i $COMID "fdisk -l | grep Disk | awk '{print $2}'" The command will produce this output: /dev/sda /dev/sdb etc.. the problem is how do I store the output in a variable in TCL, I am currently using this to grab the... (1 Reply)
Discussion started by: h0ujun
1 Replies

3. UNIX for Advanced & Expert Users

Tcl script for seaching a string ignoring white spaces

Hi , I want to search a string in a file ignoring white spaces in TCL. My string is as follows Ouput-Maps " 1 1 1 0 " 1i am doing following set a *1*1*1*0* " }1 abc.log}] but it is not working. What is the wrong with the tcl script Thanks Gouranga Video... (0 Replies)
Discussion started by: mybapa3000@gmai
0 Replies

4. Shell Programming and Scripting

Deleting part of a string : string manipulation

i have something like this... echo "teCertificateId" | awk -F'Id' '{ print $1 }' | awk -F'te' '{ print $2 }' Certifica the awk should remove 'te' only if it is present at the start of the string.. anywhere else it should ignore it. expected output is Certificate (7 Replies)
Discussion started by: vivek d r
7 Replies

5. Shell Programming and Scripting

String manipulation

I want to do the next "I don't want to go school because I'm sick today." I want to join these two line but only when the first line is not more than 20 characters and ended whit nothing or a comma and the second line not more than 15. The 20 and the 15 can be change in the script. I know... (10 Replies)
Discussion started by: thailand
10 Replies

6. UNIX for Dummies Questions & Answers

Help with String manipulation

Dear All, I have a question. I have files with the following pattern.>S8_SK1.chr01 NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNCAGCATGCAATAAGGTGACATAGATATACCCACACACCACACCCTAACACTAACCCTAATCTAACCCTGGCCAACCTGTTT... (13 Replies)
Discussion started by: pawannoel
13 Replies

7. Shell Programming and Scripting

String Manipulation

Write a shell program to display the position of the right - most character in a given input string. Example : Input : RAHUL Output : L is in the 5th position also tell me how to count length of string and how to find the position of specific character in left most side. (1 Reply)
Discussion started by: shashwat2691
1 Replies

8. Shell Programming and Scripting

Howto set string variable in TCL?

Anyone knows how to set variable in TCL ? let say i have a password variable and it will have different values. set variable and variable has different values like: xxxx yyyy zzzz (0 Replies)
Discussion started by: linuxgeek
0 Replies

9. Shell Programming and Scripting

getting a string from user while executing a tcl script

Hi All, I am executing a Tcl script and i am trying to get the user input while they execute the script at start itself like >>filename.tcl USERINPUT and then i will take this userinput inside the the tcl assign it to some variable for further manipulation/processing ...... can anyone pls... (1 Reply)
Discussion started by: sukrish
1 Replies

10. Emergency UNIX and Linux Support

TCL scripting - searching for a IP address in a string

Hi All, Can anyone please help me with the regular expression/code snippet to search for an IP address in a string with Tcl scripting. Example string "OSPF_NBRUP OSPF neighbor 16.138.181.15 (realm ospf-v2 e1-0/0/0:37.0 area 0.0.0.0) state changed from Full to Down due to KillNbr" In the... (6 Replies)
Discussion started by: Mr. Zer0
6 Replies
Login or Register to Ask a Question