TCL script to extract the file name and then create two independent list


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers TCL script to extract the file name and then create two independent list
# 1  
TCL script to extract the file name and then create two independent list

I am having one problem as stated below

Problem Description

I am having some "sv" extension files , I am using "glob" to extract the matching files , Now in these matching files , I need to split them and extract the elements and create different lists.

For example

Code:
set files [glob -type f modified_rtl_files/*/*{wrapper_hsm}*]

This command gives me these two files :

modified_rtl_files/mbist_wrapper/mbist_wpper_hsm_pkram.sv modified_rtl_files/mbi_wrapper/mbist_wrapper_hsm_sysram.sv

Now I am extracting the filename with the below command

Code:
foreach element $files {
set c [split [ file tail [ file rootname $element ] ] "_" ]
echo $c
}

This is giving me

Code:
pkram
sysram

But I need to set them to two independent list

Code:
$mem1 
$mem2 
$mem1 should be pkram 
$mem2 should be sysram

Whenever I am trying to create something like this , both the elements are getting printed

Code:
foreach element $files {                                                                                       
  set c [split [ file tail [ file rootname $element ] ] "_" ]
set d [ lindex $c 3] 
set mem1 [ lindex  $d 0 ]                                                                                                        
puts $mem1                                                                                                                       
}

It is printing both

Code:
pkram 
sysram

I want independent variables .

Last edited by kshitij; 11-05-2019 at 03:17 AM..
# 2  
[My tcl knowledge is limited,]
Do you know the two values pkram and sysram in advance? Then you can use two globs:
glob -type f modified_rtl_files/*/*{wrapper_hsm_pkram}* and
glob -type f modified_rtl_files/*/*{wrapper_hsm_sysram}*
And construct each variable separately from it.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #610
Difficulty: Medium
Compared to Python, Perl has a relatively small Comprehensive Perl Archive Network (CPAN) library.
True or False?

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

TCL script to capture range of lines and create two independent variables

Hi I am having a code as stated below module abcd( a , b , c ,da , fa, na , ta , ma , ra , ta, la , pa ); input a , b, da ,fa , na , ta , ma; output c , ra ,ta , la ,pa ; wire a , b , da , fa ,na , ta , ma; // MBIST Structures... (1 Reply)
Discussion started by: kshitij
1 Replies

2. UNIX for Beginners Questions & Answers

TCL script to insert some text on a file

Hi All , I am looking to create one TCL script to insert one text based on some regular expression match on one file as stated below Input File module (mem1 ,mem2 , bist1 , ten2 , sen1 , land2 , taane2 , ran1 , ran2 , tri2 , tri8 , fly1 , fly2 , san2 ); output ran1 , ran2 , tri2 ,... (1 Reply)
Discussion started by: kshitij
1 Replies

3. Shell Programming and Scripting

Create a list of files from alias by script

Actually I have many pictures with diferent name and size around 2000, I need generate a copy of them from one list of alias. The structure of the list is something like this: alias_list.txt <01>randomname.png<02> Randomname.png RandoMname.png RandOmname.png RandomnamE.png... (6 Replies)
Discussion started by: Tapiocapioca
6 Replies

4. Post Here to Contact Site Administrators and Moderators

Want a tcl script to compare a string in a file ignoring white spaces

Hi , I want a tcl script to search a string ignoring whitespaces in a .log file . It should correctly match . The string are as follows "Output-Maps 1 1 0 0 0" 1 and Active Intermediate-Maps 0 0 0 ... (1 Reply)
Discussion started by: kulua
1 Replies

5. Shell Programming and Scripting

Create shell script to extract unique information from one file to a new file.

Hi to all, I got this content/pattern from file http.log.20110808.gz mail1 httpd: Account Notice: close igchung@abc.com 2011/8/7 7:37:36 0:00:03 0 0 1 mail1 httpd: Account Information: login sastria9@abc.com proxy sid=gFp4DLm5HnU mail1 httpd: Account Notice: close sastria9@abc.com... (16 Replies)
Discussion started by: Mr_47
16 Replies

6. Shell Programming and Scripting

Extract date from filename and create a new file

Hi, i have a filename CRED20102009.txt in a server 20102009 is the date of the file ddmmaaaa format the complete route is /dprod/informatica/Fuentes/CRED20102009.csv i want to extract the date to create a new file named Parameters.txt I need to create Parameters.txt with this... (6 Replies)
Discussion started by: angel1001
6 Replies

7. Shell Programming and Scripting

How to extract some parts of a file to create some outfile

Hi All, I am very new in programming. I need some help. I have one input file like: Number of disabled taxa: 9 Loading mapping file: ncbi.map Load mapping: taxId2TaxLevel: 469951 --- Subsample reads (20%): 66680 of 334386 Processing: tree-from-summary Running tree-from-summary... (21 Replies)
Discussion started by: iammitra
21 Replies

8. Shell Programming and Scripting

extract columns from 2 different files and create new file

Hi All, I have 2 issues while working with file. 1. I have 2 delimited(~) files. I want to extract column numbner 3 from file1 and column number 8 from file2 and paste it into file3. I have tried using cut, but not able to get answer. 2. i have 2 filxed-width file. I wanted to do same... (1 Reply)
Discussion started by: Amit.Sagpariya
1 Replies

Featured Tech Videos