Search Results

Search: Posts Made By: useretail
1,664
Posted By Scrutinizer
Another variation: for i in *.test; do read...
Another variation:
for i in *.test; do
read new || break
mv "$i" "${i%%-*}-${new}.${i##*.}"
done <names.txt
1,664
Posted By RudiC
Try also ls *.test | while read FN && read NFN...
Try also
ls *.test | while read FN && read NFN <&3; do echo mv $FN ${FN%-*}-$NFN.${FN#*.}; done 3<names.txt
mv 01-oldname.test 01-name1.test
mv 02-someoldname.test 02-name2.test
mv...
1,664
Posted By Yoda
One approach is to load names into an indexed...
One approach is to load names into an indexed array and then use another loop to rename the files using the array:-
#!/bin/ksh

# Load names into an indexed array
c=1
while read file
do
...
1,845
Posted By Chubler_XL
That is correct, in the awk script this line:...
That is correct, in the awk script this line: !/^#/ will only print lines that don't begin with a hash (#) character.

The same applies to the bash script implemented by this line [#]*) ;;
1,845
Posted By Chubler_XL
OK this here is awk for the new output: gawk...
OK this here is awk for the new output:

gawk -v ADD_DAYS=300 '
/#(DATEA|SETTINGSBEGIN) / { print $2 }
/#VALUE TITLE/ { printf "%s\n\n", gensub(/.*"([^"]+)"/, "\\1","g") }
!/^#/' settings.txt
...
1,845
Posted By Chubler_XL
OK sorry for the misunderstanding. Here is a...
OK sorry for the misunderstanding.

Here is a GNU awk solution:

gawk -v ADD_DAYS=300 '
/#DATEA/ {
DT = mktime(gensub(/-/, " ", "g", $2) " 0 0 0")
DT += 24*60*60*ADD_DAYS
printf...
1,845
Posted By Chubler_XL
You could try this in bash script, it does...
You could try this in bash script, it does require GNU date for the date calculations:

#!/bin/bash
ADD_DAYS=300
while read line
do
[[ "$line" = [#]DATEA\ * ]] && DB=$(date -d...
1,845
Posted By Chubler_XL
You could use GNU awk like this: gawk -v...
You could use GNU awk like this:

gawk -v ADD_DAYS=300 '
/#DATEA/ {
DT = mktime(gensub(/-/, " ", "g", $2) " 0 0 0")
DT += 24*60*60*ADD_DAYS
}
/#TEXT/ {
print strftime("#DATEB...
Forum: IP Networking 08-18-2015
6,491
Posted By fpmurphy
Unfortunately, 0.0.0.0 has different meanings...
Unfortunately, 0.0.0.0 has different meanings depending on where it's used. The formal definition is given in RFC1122 Section 3.1.2.3, i.e this host on this network. Specifically, all available IP...
Forum: IP Networking 08-17-2015
6,491
Posted By Corona688
The culprit may be a "black hole" firewall...
The culprit may be a "black hole" firewall response, which instead of refusing connection just stonewalls it by ignoring the attempt.
2,975
Posted By drl
Hi. Using bash operator "=~" with extended...
Hi.

Using bash operator "=~" with extended regular expressions:
#!/usr/bin/env bash

# @(#) s2 Demonstrate extended regular expressions, bash =~.

# Utility functions: print-as-echo,...
2,975
Posted By Scrutinizer
Perhaps, but your output file specification was...
Perhaps, but your output file specification was precise. I think Chubler_XL got it right, no?

Another way of writing it would be:
sed 's/^([^)]*)-//' file

Note that the thing different from...
2,975
Posted By sea
How about: $ cat usertail TMP=~/tmp.$$ ...
How about:
$ cat usertail
TMP=~/tmp.$$
REM="ok some"
echo "(ok)-test
(ok)-test-(ing)
(some)-test-(ing)-test
test-(ing)" > $TMP

for rem in $REM
do sed s,\($rem\),,g -i $TMP
done
sed...
2,975
Posted By senhia83
maybe this will work too? awk '/^\(/...
maybe this will work too?

awk '/^\(/ {sub(/\(/,"");sub(/\)/,"")}1' infile
2,975
Posted By Chubler_XL
How about: sed 's/^[(][^)]*[)]-//'
How about:

sed 's/^[(][^)]*[)]-//'
4,989
Posted By MadeInGermany
All the previous examples do not compare with a...
All the previous examples do not compare with a constant expression.
The following does:

if [[ $string_to_report == *" "?* ]]
then
echo "has 3 spaces followed by at least one more...
4,989
Posted By Don Cragun
The updated spec is still ambiguous. The phrase:...
The updated spec is still ambiguous. The phrase: "ignoring three spaces at the end of the string" can be interpreted several ways. Any of them can be handled using standard variable expansions or...
4,989
Posted By MadeInGermany
@jim: my bash man page talks of =~ within [[ ]] ...
@jim: my bash man page talks of =~ within [[ ]]
And the ERE must be unquoted...
4,989
Posted By jim mcnamara
Hmm. Do you mean something like: [ ' f...
Hmm. Do you mean something like:

[ ' f f'~='[ ]{3}' ] && echo hi

This purposely does not directly answer your question, but shows what I think you mean.
By ignore - does that mean spaces at...
4,989
Posted By RudiC
Try TMP="${string% }" [ "${TMP}" = "${TMP/ ...
Try TMP="${string% }"
[ "${TMP}" = "${TMP/ /}" ] && echo TRUE || echo FALSE
4,989
Posted By Don Cragun
Your question doesn't make any sense. If...
Your question doesn't make any sense.
If statements don't read data from pipes.
You have shown us four echo statements (each of which prints at least three consecutive spaces piped into if...
7,410
Posted By jim mcnamara
Yes. Use his awk solution. Most sed versions do...
Yes. Use his awk solution. Most sed versions do not support ERE - what you want. awk does support it. I'm reasonably sure no other sed solution that is a single command and can be generalized...
7,410
Posted By jim mcnamara
How about something simpler replace all _ with - ...
How about something simpler replace all _ with - This gives the result you want:

echo "--_----__-___-_-__-" | sed -e 's/_/-/g'
7,410
Posted By in2nix4life
Try removing the pipe (|) symbols from your sed...
Try removing the pipe (|) symbols from your sed expression.

Also, if the goal is to have just a line of dashes, you could just globally replace the underscore character.


echo...
7,410
Posted By Scrutinizer
Standard sed cannot do it like that, you could...
Standard sed cannot do it like that, you could use 3 separate passes, but it is not the same:
sed 's/_-/-/g; s/-_/-/g; s/--/-/g' file
But that would not give the same result, since it would also...
Showing results 1 to 25 of 26

 
All times are GMT -4. The time now is 09:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy