I am new to shell script. And right now learning regular expression. I am using BASH as a shell and RedHat Linux. I have couple of doubts regarding the regular expression
1) +
This is matches one or more occurrence of the preceding pattern.
So if the file contains following data file.txt
a
aa
aba
bbb
ccc
should print following
a
aa
aba
But to print above I need to have
2) ?
should match 0 or 1 occurrence of the preceding pattern
But when I use
it pritnts nothing.. And when I use
it pritints all the data in the file. i.e output was as below
a
aa
aba
bbb
ccc
I was expecting the output as below
a
bbb
ccc
Now I have a doubt 0 or 1 means exactly 0 or 1 ?? or is it mean 0 or more then 0 ??? if it means 0 or more then 0 then whats the differnece between * (asterisk ) and ? ( question mark )??
3)
and
prints the same data as below
a
aa
aba
I was expecting this output only when I use
and should print below line when I use
a
Hi,
In some machines when i type "clear" it completely clears all the contents on that window but on some it simply scrolls up all the content.
How can i change this? (4 Replies)
:confused: some one please tell me where i can possibly find out what is unix 10.2 and the basic system functions of it is. I really need help! (1 Reply)
I'm an intern at a company that recently bought out another business. In doing so, they inherited a unix system that contains files which they need to retrieve. No one in the company, including myself, really understands or knows unix so please respond with the true assumption that I'm a unix... (1 Reply)
Good day, everyone!
Could anybody explain me the following situation.
If I'm running similar script:
Var="anna.kurnikova"
Var2="Anna Kurn"
echo $Var | tr -t "$Var" "$Var2"
Why the output is :
anna KurniKova
instead of Anna Kurnikova?
:confused:
Thank you in advance for any... (2 Replies)
Hi,
I was trying to learn forking in C in UNIX. Somehow i still haven't been able to get the concept well. I mean, i do understand that fork creates an exact replica of the parent (other than the fact that parent gets the process id of the child and child gets 0 when fork is called). This is the... (2 Replies)
Hi all,
How am I read a file, find the match regular expression and overwrite to the same files.
open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat";
open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat";
while (<DESTINATION_FILE>)
{
# print... (1 Reply)
Hi friends,
This is a small program built on the concept of shared memory. The producer is a separate program and process, and the consumer is a seperate program and process. Both are executed under the same user account. The producer takes some string from the user and adds that string to the... (1 Reply)
I don't even know where to start with this one. There is so much out there about different aspects of this. I am starting with a basic Ubuntu 11.04 install. Do I need to configure a DNS? I am a little confused about that. What do I need to do for a domain name? I have followed various tutorials,... (1 Reply)
Hello All,
I have a problem in counting number of process getting run with my current script name..
Here it is
ps -ef | grep $0 | grep -v grep
This display just one line with the PID, PPID and other details when i print it in the script.
But when I want to count the numbers in my... (11 Replies)