Cut out string in bash script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cut out string in bash script
# 8  
Old 02-22-2010
Thanks durden_tyler,
that's more ways to do it that I'll ever need to have Smilie
# 9  
Old 02-26-2010
Sorry for little bit of necro...

I have extension to my problem:
protocol doesn't have to be 'http', so it could be anything before '://' signs.

Also, second way more simple thing: how to get url protocol, again anything before '://url.com/blablabla'
# 10  
Old 02-26-2010
Quote:
Originally Posted by cootue
Sorry for little bit of necro...
Not sure how that fits in here. "necro" = corpse, death, dead tissue etc. (Necro | Define Necro at Dictionary.com) But anyway, I digress.

Quote:
I have extension to my problem:
protocol doesn't have to be 'http', so it could be anything before '://' signs.
So here's the same file "f6" again, with a few non-http protocols thrown in:

The Perl script below fetches the word that is between "://" and ".".
If this word has one or more digits at the end, then are left off.
If this word has one or more digits in the middle, or at the beginning, they are retained.

Quote:
Also, second way more simple thing: how to get url protocol, again anything before '://url.com/blablabla'
Here's the Perl script that fetches the protocol from the URL -

HTH,
tyler_durden
# 11  
Old 02-27-2010
Thanks,
durden_tyler, looks like perl is way to go Smilie

And 'necro', like... to revive topics from the dead. Or maybe it was some other word? Hehe.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies

2. Shell Programming and Scripting

Passing string from SQL to a BASH script

OS Solaris 10, DB oracle 10g Hello, We currently have a BASH script that runs and moves image files from a remote server to the local db server. A snippet of the code shows that we are picking up all Images that are 'mtime -1' some code... for file in `ssh user@10.200.200.10 'find... (3 Replies)
Discussion started by: JonP
3 Replies

3. Shell Programming and Scripting

Need script to cut string from a filename

Hi, I need a script which do below I have a filename: TEST2013_09_17_XX_XX_XX.csv Now script should create a new file with name: XX_XX_XX.csv Or I should say i need the output as XX_XX_XX.csv Please help. Mant thanks in advance (3 Replies)
Discussion started by: sv0081493
3 Replies

4. Shell Programming and Scripting

Requesting help to replace a string by my bash script

Hello every1, I need help to replace a string in a file by my bash script. Find: log4j.appender.toLogFile.layout.ConversionPattern= %d %5p (%F:%L) - %m%n= %d %5p (%F:%L) - %m%n Replace: log4j.appender.toLogFile.layout.ConversionPattern= %d %5p (%F:%L) - %m%n I tried by sed, but kept... (7 Replies)
Discussion started by: titanic4u
7 Replies

5. Shell Programming and Scripting

bash script tail when string found do something

Okay, I have two scripts, the first one does some stuff, and comes to a point where it has this: Right here it runs a quick script to start something that writes to a log file. /usr/bin/tail -f ${pathVar}/nohup_${servVar}.out | while read -r line do ] && continue cd ${pathVar}... (0 Replies)
Discussion started by: cbo0485
0 Replies

6. Shell Programming and Scripting

bash shell script string comparison

I want to remove a line that has empty string at second field when I use cut with delimeter , like below $cat demo hello, mum hello, #!/bin/sh while read line do if then # remove the current line command goes here fi done < "demo" i got an error message for above... (4 Replies)
Discussion started by: bonosungho
4 Replies

7. Shell Programming and Scripting

Bash script for searching a string

Hi, I have a file that contains thousands of records. Each record starts with "New Record". I need to search this file based on a given value of "timestamp" and write all the records that match this timestamp into a new file. I was able to locate the existence of a given value of timestamp using... (10 Replies)
Discussion started by: shoponek
10 Replies

8. Shell Programming and Scripting

bash script to check the first character in string

Hello would appreciate if somebody can post a bash script that checks if the first character of the given string is equal to, say, "a" thnx in advance (2 Replies)
Discussion started by: ole111
2 Replies

9. Shell Programming and Scripting

read string, check string length and cut

Hello All, Plz help me with: I have a csv file with data separated by ',' and optionally enclosed by "". I want to check each of these values to see if they exceed the specified string length, and if they do I want to cut just that value to the max length allowed and keep the csv format as it... (9 Replies)
Discussion started by: ozzy80
9 Replies

10. UNIX for Dummies Questions & Answers

Shell script: Cut / (slash) character in string

I have a string "\/scratch\/databases\". I want to have a new string "\/scratch\/databases" by cutting last '\' character using shell script. I can't do this Please help me. Thanks in advance ThuongTranVN (4 Replies)
Discussion started by: ThuongTranVN
4 Replies
Login or Register to Ask a Question