Shell or Perl (adding quote around path)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell or Perl (adding quote around path)
# 1  
Old 08-08-2012
Shell or Perl (adding quote around path)

Hi Experts,

I have a line as below:
Code:
Text 351:2139 /opt/bo/boexi30/bobje/data/.bobj/registry/software/business objects/suite 12.0/olap intelligence/occa(o)

What I need is:
add a single quote around the path as below:
Code:
chown 351:2139 '/opt/bo/boexi30/bobje/data/.bobj/registry/software/business objects/suite 12.0/olap intelligence/occa(o)'

NOTE the space between the directory name: business objects/

Please help in this.

Last edited by apatil65; 08-09-2012 at 09:45 AM.. Reason: code tags
# 2  
Old 08-08-2012
Code:
$ perl -pe "s/([0-9] )/$1 \'/;s/$/\'/" input.txt
Text 351:213 '/opt/bo/boexi30/bobje/data/.bobj/registry/software/business objects/suite 12.0/olap intelligence/occa(o)'

---------- Post updated at 04:22 PM ---------- Previous update was at 04:17 PM ----------

Code:
$ sed "s/\([0-9] \)/\1\'/;s/$/\'/" input.txt
Text 351:2139 '/opt/bo/boexi30/bobje/data/.bobj/registry/software/business objects/suite 12.0/olap intelligence/occa(o)'

why your output has chown ? instead of Text ?
# 3  
Old 08-08-2012
Sorry, its not chown, its text only.

---------- Post updated at 07:39 AM ---------- Previous update was at 07:27 AM ----------

Thanks a lot.
You have taken numbers as a delimiter, But what if its:
Code:
Text 351:2139 /opt/bo/boexi30/bobje/data/.bobj/registry/software/business objects/suite 12.0/olap intelligence/occa(o)
mkdir /users/home/xbbjny5

I need single quote to whole path ?

Please help.....

---------- Post updated at 07:41 AM ---------- Previous update was at 07:39 AM ----------

I got it.........!!! i did:
Code:
sed "s/\([0-9] \)/\1\'/;s/$/\'/" | sed "s/\([a-z] \)/\1\'/;s/$/\'/" abc.txt

---------- Post updated at 07:41 AM ---------- Previous update was at 07:41 AM ----------

Thanks a lot Smilie

---------- Post updated at 07:44 AM ---------- Previous update was at 07:41 AM ----------

Ohh no.... Smilie its wrong.....
please help...

Last edited by apatil65; 08-09-2012 at 09:46 AM.. Reason: Franklin: Please use code tags for data and code samples, zaxxon: code tags please; you already got a PM about it.
# 4  
Old 08-08-2012
Quote:
Ohh no.... its wrong.....
please help...
Please do not leave people guessing. Show a representative sample of input, desired output, attempts at a solution and specify what OS and versions being used.
Also start using code tags as you were asked by me 2 times and 1 time by Franklin52 already. Read your PMs.
# 5  
Old 08-09-2012
thanks

Moderator's Comments:
Mod Comment apatil65 banned for refusing to use code tags, then editing all posts and deleting mod instructions and prior posts.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding to the end of the path in .profile

Hi there, I have the following in my path: export PATH=/usr/bin:/usr/sbin But I want to change it programmatically(for the purpose of JBoss automatic(ansible) installs) to: export PATH=/usr/bin:/usr/sbin:/usr/jdk/jdk1.8.0_60 and after that I need to insert the JAVA_HOME programmatically,... (7 Replies)
Discussion started by: hvdalsen
7 Replies

2. Shell Programming and Scripting

Replacing all but the first and last double quote in a line with a single quote with awk

From: 1,2,3,4,5,This is a test 6,7,8,9,0,"This, is a test" 1,9,2,8,3,"This is a ""test""" 4,7,3,1,8,"""" To: 1,2,3,4,5,This is a test 6,7,8,9,0,"This; is a test" 1,9,2,8,3,"This is a ''test''" 4,7,3,1,8,"''"Is there an easy syntax I'm overlooking? There will always be an odd number... (5 Replies)
Discussion started by: Michael Stora
5 Replies

3. HP-UX

Adding Directories to PATH in HP-UX with csh

HI Guys, I am truing to add some directories to the productive HP-UX (like /usr/sbin) the problem is that i tried some methods like (export) and setenv but i failed. I add some logs output of the commands to provide you with more info . the user which I am trying to add this path is different... (5 Replies)
Discussion started by: barry1946
5 Replies

4. UNIX for Dummies Questions & Answers

perl awk system quote probems

Hey guys, I'm having some issues escaping quotes and getting the following line to run in perl. The quotes are really messing me up. system (" awk 'BEGIN{FS="/t";OFS=","} {print \$1,$fieldNum}' $file > output.csv "); (1 Reply)
Discussion started by: WongSifu
1 Replies

5. Shell Programming and Scripting

[Solved] Not able to quote perl function in sprintf() !

The required form of command is as perl /product/editique/RFR/preproc/scripts/ExprEval.pl -P 'EGAL_CHAINE (" ","")' -K /varsoft/editique/RFR/preproc/logs/D.RFR.PR.PCAC9.PCPA.00.54.20110920.Evaluate_Expression.logWhat's wrong with this code (it is not quoting the function, I have checked... (1 Reply)
Discussion started by: ezee
1 Replies

6. Shell Programming and Scripting

replacing a quote in some lines with multiple quote fields

i want to replace mistaken quotes in line starting with tag 300 and relocate the quote in the correct position so the input is 223;25 224;20100428064823;1;0;0;0;0;0;0;0;8;1;3;9697;18744;;;;;;;;;;;; 300;X;Event:... (3 Replies)
Discussion started by: wradwan
3 Replies

7. Shell Programming and Scripting

Regex in grep to match all lines ending with a double quote (") OR a single quote (')

Hi, I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file: Name = "abc" The regex I'm using to match the same is: egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
6 Replies

8. UNIX for Dummies Questions & Answers

adding PATH variable

Hello i use bash and i added a path variable for 2 files /rscr and /uscr in /etc/profile /rscr working fine but the other one shows command not found and when i try to type whereis for scripts in /rscr it shows them but the other one shows nothing... thanks :b: (3 Replies)
Discussion started by: wir3d
3 Replies

9. UNIX for Dummies Questions & Answers

Adding default search path for CPP

Hi there, I have built myself a GCC (3.4.4) for PowerPC with a cross compilation toolchain running on a x86, together with glibc-2.3.4 and binutils-2.16. On the PowerPC there is a system runnign already (only console ofc, nothing "cosy", kernel-2.6.15). So my question is how to propperly... (1 Reply)
Discussion started by: boyanov
1 Replies

10. UNIX for Dummies Questions & Answers

Adding PATH variable in the startup scripts

Hi, I got a error message The environmental variable AUTOSYS is not set ! I think I require to to add a path to PATH variable in the startup scripts in the home dir. I tried using set PATH= but it is not setting the PATH when i do the echo $PATH , i dont get the new PATH reflected, Is... (5 Replies)
Discussion started by: rajanishshetty
5 Replies
Login or Register to Ask a Question