Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Could someone please explain to me what is going on here..
File1
Code:
/oracle/syn/ccs/ccsora/admin/ccs/bin/mkSQLLdr: No such file or directory
merlin|oraccs|CCS> more mkSQLLdr
#!/bin/sh
files=`(ls data/*.dat)`
for file in $files
do
if [ -f $file ] ; then
ex -s $file< file2
fi
done
a list of files are processed by ex for regular expression matches. we can't really tell you much more than that an i expect you already know that. if you want to know what each regex does, then just google for a 101 about regular expressions. it's really hard to give you a meaning that you'll care about without any contextual data to relate them to.
As you can see the @ sign in the email address (Columns 7) was also replaced with the " sign. I need to understand how it works so that i can prevent it from replacing the @ sign on the email address.
well that's one of them.... g/@/s/@/"/g. this reads, "for all lines (g/) which contain an @ (@), substitute (/s/) the @ (@) for a (/) Double quote (") in every instance (/g)"
if you want to avoid the email being battered, you'd need to improve the regex to be fussier. you would probably be best breaking it into multiple ones or it'll get a lot messier. so rather than replacing @ with ", replace '@,@' with '","', '^@' (@ at start of line) with ',' and '@$' (@ at end of line) with '"' in three separate goes. you *could* do it in one, but i doubt you'll really care to optimize like that.
way to get BT spammed btw...
Last edited by acid_kewpie; 11-05-2007 at 06:02 AM.
I understood the bit about replacing the @,@ with ",". I think i can do this by replacing g/@/s/@/"/g with /g/@,@/s/","/"/g
Could you explain in a bit more detail on how i can replace the @ sign at the begning of the line and the @~~ at the end of the line. The ~ character seem to be used all over the place and im not sure why.
And also you mentioned that /g means every instance. What do the other values mean? v,d, s, j, w and q.
Thanks
ps. i've edited the post to remove the company name. Could you also edit your post to remove reference to the company name.
your regex is wrong, but more becuase you don't really *need* the g/ part anyway, as you're just replicating what you already know. so just try '%s/@,@/","/g', without the g/@,@/ stuff at all to replace all lines (the % sign just means all lines). (check a vi cheat sheet for more knowledge about what this is doing)
and BT deserve all they get.. they make my working life hell, the chimps.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.