[VIEWED 5338
TIMES]
|
SAVE! for ease of future access.
|
|
|
Junkiri
Please log in to subscribe to Junkiri's postings.
Posted on 06-29-07 12:46
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Hi All, I need some help writing a script in bash shell that does the following. I have a bunch of files with letters before some numbers ( those numbers are the identifiers of the files that I will finally need to weed out). I need to remove the letters before the numbers so that the file name start with the numbers alone (I don't care about the letters after the numbers). Here's an example of what I have and what I want finally to make things more clear: What I have now: SGDUNK223.R_D02_08.ab1 What I'd like to have: 223.R_D02_08.ab1 I could either do this one by one....but figured a script could make my llife a lot easier and I could do more interesting stuff like visiting sajha :D.
|
|
|
|
Danger
Please log in to subscribe to Danger's postings.
Posted on 06-29-07 1:12
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
I dont know in Shell but in SAS you can use the SUBSTR function. I guess there has to be something similar in shell s. Prob this is what u want. http://www.linuxforums.org/forum/linux-programming-scripting/44758-extracting-substring-string.html
|
|
|
Junkiri
Please log in to subscribe to Junkiri's postings.
Posted on 06-29-07 1:23
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
There should be an easier way to this...Thanks anyway....any Unix experts out there?
|
|
|
Danger
Please log in to subscribe to Danger's postings.
Posted on 06-29-07 1:33
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
U can write a macro in sas that would do all that in one step. Sorry There are some experts here. Well I failed my last interview just bec of that question
|
|
|
|<1$|-|
Please log in to subscribe to |<1$|-|'s postings.
Posted on 06-29-07 3:13
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Hope this one helps. If you are looking for something else, let me know.. #!/bin/bash MYVAR="SGDUNK223.R_D02_08.ab1" NAMEONLY=`expr match $MYVAR '\([a-zA-Z]*\)'` RESULT=${MYVAR#$NAMEONLY} echo $RESULT
|
|
|
lanthus
Please log in to subscribe to lanthus's postings.
Posted on 06-29-07 5:11
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
yes i think |<1$|-| is absolutely correct. that will definately work. if not please post i will try to help you. but that will work
|
|
|
incognito_kanchi
Please log in to subscribe to incognito_kanchi's postings.
Posted on 06-29-07 6:23
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
what type of files are these. Script by |<1$|-| should work.
|
|
|
Danger
Please log in to subscribe to Danger's postings.
Posted on 06-29-07 9:28
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Hey Unix people How do I know how many lines of codes are there in a particular program?
|
|
|
|<1$|-|
Please log in to subscribe to |<1$|-|'s postings.
Posted on 06-29-07 9:45
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
If you are talking about a source file, then type the following at the shell: wc -l filename
|
|
|
Junkiri
Please log in to subscribe to Junkiri's postings.
Posted on 06-29-07 9:47
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Hi all, Thanks so much for your help....I ended up working on other stuff and saving this for next week..So I will try the script that you suggested and hopefully this will work.Otherwise I will have to change the names individually...and doing that for 1000+ files is definitely a pain in the rear :S. Btw, I will need to write more scripts in the future..I will probably have to look into perl or other scripting languages later on but for now I just need to polish up my shell scripting. I am actually looking for a good book for this. Any suggestions? I heard O'Reilly books are really good. Incognito_kanchi, Those files are actually generated from a program called sequencher, used in DNA sequencing. Thats as far as I know coz I am also relatively new to this area. Danger, I think this should work: cat n1 | wc where n1 is the name of the program (file). This gives the number of characters, words and lines in the file. Hope this helps.
|
|
|
Danger
Please log in to subscribe to Danger's postings.
Posted on 06-29-07 11:17
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Thanks I can score my next interview now. Rookie here. Oops w/ 5 yrs of linux experince cause my sitty SAS runs on Linux and Mainframe. By the way do you know how to transfer files from Linux to PC and Mainframe? That is another question thats bothering me???
|
|
|
|<1$|-|
Please log in to subscribe to |<1$|-|'s postings.
Posted on 06-29-07 11:35
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
junkiri, I use the Advanced Bash-Scripting guide http://tldp.org/LDP/abs/html/ Danger, There are a lot of ways to transfer files. Try rsh or ssh. You can get free ssh client for windows.
|
|