473,395 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Quoting a system call - double vs single

20
Hi, i faced a problem while executing code in double quote "" and single quote ''

let say example, we type in manually:

>ls abc | grep "\.\/"

it works.

and when i implement this into my script.

$cmd1 = "ls abc | grep '\.\/'" #------> not working
$cmd2 = "ls abc | grep \"\.\/\" # same like previous.

Is my syntax correct ? Please advice. Thank you.
Aug 23 '07 #1
2 1751
numberwhun
3,509 Expert Mod 2GB
Not exactly. When you run a system level command in Perl, you either use the system function, or you have to put the system level command in back tics. They essentially do the same thing. Here is how your command should look:

Expand|Select|Wrap|Line Numbers
  1. my $cmd1 = 'ls abc | grep "./"';
  2.  
I don't have my linux box up at the moment to test if you need the leading"\" characters, but you can play with it and see what works for you to get the results you want.

Regards,

Jeff
Aug 23 '07 #2
DannyMc
20
Thanks Jeff, you reminded me to put the 'single quote' first before the "double" quote!! I have solved my minor problem now.

Actually i have created a function to search for files for me inside a system. i will named it "getme" in this case.

>getme name.cpp

my function will print the result like this

File(s) Found:

./abc
./123
./321

So i just want to grep the result which is ./abc instead of the whole printed message.

"\" forward slash is important in the grep. Without \ , it result still print complete message. You can have a try with webbased ubuntu. :)

Thank you once again , i appreciate it !
Aug 23 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: surrealtrauma | last post by:
i have a trouble about that: i want to ask user to enter the employee data (employee no., name, worked hour, etc.), but i dont know how to sort the data related to a particular employee as a...
7
by: AznCollegeGuy | last post by:
Hello, Im trying to invoke a simple perl script with in my visual c++ gui program to with c++'s system call feature: when i call: system("dir"); it works
1
by: jsnX | last post by:
if i wanted to call system with an argument to a function that had double quotes and backslashes in it - for example perl -e 'print "hello world\n"; ' how would i make that work? would it be:...
13
by: Jon Agiato | last post by:
Hello, I am sure this problem is easy to spot but I have been at this project all day and the frustration has finally overcome me. I am using this function in order to produce a standard normal...
9
by: MDoyle | last post by:
Here is the easiest question you’ll get all day from a complete newbie. I installed Visual Studio on my laptop last night and have been tryin to write my very first C# programs this morning. I’m...
6
by: Philip Warner | last post by:
I have a set of classes: C (base) C1 (inherits C) C2 (inherits C) ... Cn (inherits C) (the C1..Cn also have subclasses, but thats not really relevant to the question)
62
by: Laurent Deniau | last post by:
I just put the draft of my paper on the web: http://cern.ch/laurent.deniau/html/cos-oopsla07-draft.pdf I would be interested by any feedback from C programmers (with little OO knowledge) to...
7
by: Steven W. Orr | last post by:
Python has a number of "quoting" 'options' to help """with times when""" one way may be more convenient than another. In the world of shell scripting, I use a technique that I call minimal...
12
by: aaragon | last post by:
I have this scenario: several arrays for which I have their fixed values at compilation time. Now, at runtime I need to access a specific array depending on an integer but I want to avoid if and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.