Help me with shell script command to print


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help me with shell script command to print
# 1  
Old 07-15-2013
Help me with shell script command to print

I have a file with similar line like below

/u13/orabkup/u13/orabkup/abcd/arc82.123

Now I need to have only u13/orabkup/abcd/arc82.123 rather than /u13/orabkup/u13/orabkup/abcd/arc82.123

Kindly help me to print /u13/orabkup/ only once and the file name abcd/arc82.123..

Thanks & Regards
Anitha
# 2  
Old 07-15-2013
sed

Hey!!!

Please use code tags for data samples and codes.

Try sth like,

Code:
sed -i.bak 's/\(\/[^/]*\/[^/]*\)\1/\1/g' file_name

Here this command will work for your requirement like below.

Code:
/ori_string1/ori_string2/dup_str1/dup_str2/other_str/
 
Ouput will be,
 
/ori_string1/ori_string2/other_str/

Cheers!!
-R
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print statement in shell script

Hi All, when I executed the query in normal unix mode, the output is expected. if I executed the query using shell script, I am not getting the result. not sure whether I need to use dbms_output.put_line or echo. dbms_output.put_line("COUNTRY_CODE"||" "||"SUB_TYPE"||" ... (3 Replies)
Discussion started by: arun888
3 Replies

2. Shell Programming and Scripting

Print 1 to 10 with space in shell script

Hi, I want to print 1 to 10 or upto any number sequentially with space in a single line. Like, 1 2 3 4 5 6 7 ...... In shell script only.. Can anyone plz help me. Thanks: (14 Replies)
Discussion started by: arup1980
14 Replies

3. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

4. Shell Programming and Scripting

Shell script to print date and no.of records

hi all, i want script to print the output in the following format filename yyyy/mm/dd count where count= no.of records in the file Thanks in advance hemanthsaikumar (11 Replies)
Discussion started by: hemanthsaikumar
11 Replies

5. Shell Programming and Scripting

print output of a command in same as shell in mail : please help

i have written a simple script to print the out of a command and send an mail but i am not getting a shell output here .please see my script present output is like this i need an output as same as shell Postfix log summaries for Jan 24 Grand Totals ------------ messages 1432 received 1439... (2 Replies)
Discussion started by: unimaxlin
2 Replies

6. UNIX for Dummies Questions & Answers

Linux Shell Question: how to print the shell script name ?

Suppose I have a script named "sc.sh" in the script how to print out its name "sc.sh"? (3 Replies)
Discussion started by: meili100
3 Replies

7. Shell Programming and Scripting

shell script to print '*' triangle

plz tell me how to print * triangle like this * ** *** **** ***** (12 Replies)
Discussion started by: akash
12 Replies

8. Shell Programming and Scripting

perl - why is the shell script executed before the print command?

i'm writing some simple scripts to help me learn perl. why does the print command get called after the shell script is executed? the purpose of the shell script is to simply echo to the screen "script run". which is does, but before the print command, you can clearly see the shell script is... (3 Replies)
Discussion started by: mjays
3 Replies

9. Shell Programming and Scripting

to print output using shell command

suppose u have 2 files ; where both files have one line in common. say one file like that >gi|62859953|ref|NP_001017322.1| plexin B2 MKEKERTKAITEIYLTRLLSVKGTLQQFVDNFFQSVLNSNQVVPPAVKYFFDFLDEQAEKYEIKDEDTVHIWKTNSLSLR... (13 Replies)
Discussion started by: cdfd123
13 Replies
Login or Register to Ask a Question