sed command for picking a part of line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed command for picking a part of line
# 1  
Old 10-31-2011
sed command for picking a part of line

Hello Friends

I want to use sed command to pick a part of line. FOr example I only need the

/home_put1/bidds/myfo

part of following line

fish://ulavet@rits1.ula.com.tr/home_put1/bidds/myfo

How can I do this bu using sed command ?
# 2  
Old 10-31-2011
Code:
echo 'fish://ulavet@rits1.ula.com.tr/home_put1/bidds/myfo' | sed 's#.*//[^/]*/#/#'

This User Gave Thanks to Shell_Life For This Post:
# 3  
Old 10-31-2011
You got a similar request in your other thread https://www.unix.com/shell-programmin...ariable-3.html where nobody answered anymore. Please keep to that thread and do not open a new thread for the same problem, thanks.
Also the solutions provided might give you a clue how it could work with sed. Try it out yourself - you can't damage or harm anything.

Also use code tags instead of coloring everything in different colors. There are people that are color blind so code tags are usually sufficient and more appropriate.

To see how code tags are being used:
code tags <- click the link!

-closed-

Lucky you, there is an answer already.
This User Gave Thanks to zaxxon For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Cherry picking with sed?

#!/bin/bash shuffle() { Deck=$(shuf -e {2,3,4,5,6,7,8,9,T,J,Q,K,A}{H,S,D,C}) } PH=(6H 9S KC) # playerhand CH=(JD 4D) # computerhand AC=2S # activecard shuffle echo $Deck I am unsure about how to proceed. I want to reshuffle a deck but without the cards in... (3 Replies)
Discussion started by: cogiz
3 Replies

2. Shell Programming and Scripting

sed - How to replace right part of equal sign (=) on a line

Hello. Using a bash script , I have a variable name for the file I want to modify FILE_TO_EDIT="/etc/my_config_file"And I have a variable name for the parameter to change PARAMETER="fallback_node" PARAMETER_NEW_VALUE="http://my_server_name.com/new_path" A config file may contain : 1°)... (2 Replies)
Discussion started by: jcdole
2 Replies

3. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies

4. UNIX for Dummies Questions & Answers

sed or awk - removing part of line?

hi all, I am having trouble finding the right string for this - I dont know whether to use awk or sed.. If I have a file with alot of names and phone numbers like this McGowan,Sean 978-934-4000 Kilcoyne,Kathleen 603-555-1212 Club603,The 617-505-1332 Boyle,William 301-444-1221 And... (11 Replies)
Discussion started by: alis
11 Replies

5. Shell Programming and Scripting

Using Sed to remove part of line with regex

Greetings everyone. Right now I am working on a script to be used during automated deployment of servers. What I have to do is remove localhost.localdomain and localhost6.localdomain6 from the /etc/hosts file. Simple, right? Except most of the examples I've found using sed want to delete the entire... (4 Replies)
Discussion started by: msarro
4 Replies

6. Shell Programming and Scripting

change part of a line with sed

Hi gurus, I'd like to change this complete line on a file: BAN_COMMAND="/etc/apf/apf -d $ATTACK_HOST {bfd.$MOD}" to this one: BAN_COMMAND="/sbin/iptables -A INPUT -s $ATTACK_HOST -j DROP" I've tried a lot without any successful . :( thanks in advance Israel. (2 Replies)
Discussion started by: iga3725
2 Replies

7. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line. ... (1 Reply)
Discussion started by: cbo0485
1 Replies

8. Shell Programming and Scripting

Replace part of a line with sed/awk

Hello I have a document and in this document I have several occurrence of "VAR == xxxxxxx" and xxxxx can be anything. I don't know what it is. I want to replace the 'xxxxx's with something I know. What I know however, is the line numbers of the VAR =='s in the file. How can I replace... (1 Reply)
Discussion started by: alirezan
1 Replies

9. Shell Programming and Scripting

Getting sed to work on part of a line

I been trying to get this right. I have trying to get rid of spaces in between the character < and the character >. Everytime I try, sed gets too greedy and do the whole line. Ex. < T AG 1> Hello, how are you doing? <Tag 2> I am doing fine. I want this: <TAG1> Hello, how are you... (6 Replies)
Discussion started by: quixoticking11
6 Replies

10. UNIX for Advanced & Expert Users

CPU Part Number from the command line (Solaris 8)

How Could I get the CPU Part Number from the Solaris command prompt? (Solaris 8 E4500 Server) Thanks in advance. Hugo (2 Replies)
Discussion started by: hugo_perez
2 Replies
Login or Register to Ask a Question