The following will extract the first component of the url and strip any trailing digits that may be present (leading or embedded numbers are left intact):
@durden tyler
Quote:
Originally Posted by durden_tyler
That perl will not work if the trailing digit is not present or if there's a digit embedded elsewhere in the name. The latter may be unlikely, but the original query states that the digit is not always present.
...
That perl will not work if the trailing digit is not present or if there's a digit embedded elsewhere in the name. The latter may be unlikely, but the original query states that the digit is not always present.
...
Sorry, my bad.
Here's a file that contains variations of the URL, with the digit at the end, at the beginning, in between, and non-existent.
Here's the Perl equivalent of your second awk script i.e. remove digit at the end (if present), but retain digit in-between or at the beginning (if present). Otherwise just fetch the word between "//" and "." that does not have any digits.
Since nothing has been mentioned about the case when the digit is at the beginning or in-between, I shall consider a couple of cases.
Case 1:
The digit at the beginning is to be removed.
The digit in-between has to be retained.
The digit at the end is to be removed.
Which means - "remove digits from the ends, retain it in the middle".
Case 2:
The digit at the beginning is to be removed.
The digit in-between has to be removed.
The digit at the end is to be removed.
Which means - "remove digits from the ends and the middle".
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)