Search Results

Search: Posts Made By: jcdole
7,368
Posted By Scrutinizer
Hi, try double quotes: sed...
Hi, try double quotes:
sed "s/${TOKEN1}\(.*\)${TOKEN2}.*/\1/" "$INPUT1"
The curly braces for variable expansions are good practice within strings, for reasons of readability and also to prevent...
9,298
Posted By RavinderSingh13
Hello jcdole, Yes, that could be shorten to...
Hello jcdole,

Yes, that could be shorten to following.

MY_PATTERN="="
SOME_VAR=$(awk -F"$MY_PATTERN" '{split($1,array," ");print array[3]}' Input_file)
echo "$SOME_VAR"


Thanks,
R. Singh
9,298
Posted By Yoda
Using built-in parameter substitution...
Using built-in parameter substitution (https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/osmanagement/korn_shell_parmsub1.html):-

while read line
do
SOME_VAR="${line%%=*}"
...
5,651
Posted By RudiC
This might work: awk "/zypper_local/ && /60/ &&...
This might work:
awk "/zypper_local/ && /60/ && /${ZYPPER_LOCAL_REP//\//\\/}/" file; or try (given the order of the substring is as given):

grep "zypper_local.*60.*$ZYPPER_LOCAL_REP" file

...
5,651
Posted By ctsgnb
Give a try replacing your : awk...
Give a try replacing your :



awk '/zypper_local/ && /60/ && /$ZYPPER_LOCAL_REP/'with :

awk -vP="$ZYPPER_LOCAL_REP" '/zypper_local/ && /60/ &&($0~P)'


You can also try to get out the...
5,929
Posted By Chubler_XL
Here I used awk to replace everything except "#"...
Here I used awk to replace everything except "#" on your "ยง" line with spaces. This is used as a template to insert the required comments:
awk -v D=2019_08_25 -v V=34-1-9 -v M=9-7-3 '
function...
9,601
Posted By Chubler_XL
Try: find path \( \ \( [condition A] \)...
Try:
find path \( \
\( [condition A] \) -prune -o \
\( [condition B] \) -prune -o \
\( [condition C] \) -prune \
\) -o -print


Example:

$ mkdir -p...
1,461
Posted By RudiC
It is a "bracket expression" at begin-of-line...
It is a "bracket expression" at begin-of-line ("^", as you used it in your substitution). man regex:
1,461
Posted By RudiC
You escaped one address delimiter too many. man...
You escaped one address delimiter too many. man sed:


Try your sed command again, with the second | unescaped.


To avoid commenting out an already commented line, you can either add the # ...
1,159
Posted By MadeInGermany
It's okay. If all of you directories start with...
It's okay.
If all of you directories start with $A_START_PATH
then you can perhaps cd to it and use shorter names (relative to the current directory).
cd "$A_START_PATH" || exit
A_LIST="dir1 dir4...
37,271
Posted By MadeInGermany
No, it is because .* matches .. and . Test the...
No, it is because .* matches .. and .
Test the glob expansion with echo!
This is for the arguments = start files.
If one of the start files is a directory, chown -R will recurse into it and find...
1,250
Posted By drl
Hi. Does this demonstration help? ...
Hi.

Does this demonstration help?
#!/usr/bin/env bash

# @(#) s1 Demonstrate calling function from find -exec.

# Utility functions: print-as-echo, print-line-with-visual-space, debug....
8,194
Posted By Chubler_XL
rsync has no concept of hidden files and...
rsync has no concept of hidden files and processes both files identically for me.

See my testing transcript below where both files copied OK:

$...
2,299
Posted By disedorgue
Hi, You are this problem because when used in...
Hi,
You are this problem because when used in a function, the built-in declare makes local variable. The -g option suppresses this behavior.

A solution could be:
declare -p ARRAY_MAIN_REPO_LEAP...
1,960
Posted By MadeInGermany
-o is OR within [ ] (and in test arguments) ||...
-o is OR within [ ] (and in test arguments)
|| is OR in the shell
So it is either
if [ $x -gt 0 -o $y -gt 0 ] ; thenor
if [ $x -gt 0 ] || [ $y -gt 0 ] ; then
999
Posted By RavinderSingh13
Hello jcdole, Could you please try following...
Hello jcdole,

Could you please try following and let me know if this helps you.

VAR1=$(grep -oE '.*ext4[[:space:]]+' Input_file)
VAR2=$(grep -oE 'acl.*[[:space:]]+' Input_file)
Now be very...
2,685
Posted By Don Cragun
Without quotes, the words in the expansion of...
Without quotes, the words in the expansion of $MY_TOKEN are passed to echo as separate arguments by the shell. The echo utility then prints each of its arguments separated by a <space> character and...
2,685
Posted By RudiC
MY_TOKEN is not define anywhere, so any output is...
MY_TOKEN is not define anywhere, so any output is somewhat surprising...
The first two outputs are identical, and should be - the curly braces are meant to protect a variable name and should not...
2,847
Posted By Chubler_XL
This solution has evolved over the weekend but as...
This solution has evolved over the weekend but as there have been no further replies I'll update in-place.

My final solution avoids changes of $IFS and the set -f builtin. Firstly an example of...
5,355
Posted By RudiC
Would this help?echo "ABCDEF+1234" | grep -E...
Would this help?echo "ABCDEF+1234" | grep -E "[\x26-\x40]"
grep: Invalid range end
echo "ABCDEF+1234" | LC_ALL=C grep -E "[\x26-\x40]"
ABCDEF+1234

---------- Post updated at 17:49 ----------...
10,524
Posted By RudiC
You could use echo $L_TEMP | grep -v...
You could use echo $L_TEMP | grep -v "[^[:print:]]"
or, with a recent shell, L_TEMP_TEST=${L_TEMP//[[:print:]]}The second would leave L_TEMP_TEST empty if no non-printable chars are in the variable,...
10,524
Posted By RudiC
Try L_TEMP=$a$'\x07'$b or L_TEMP=$a$'\a'$b
Try L_TEMP=$a$'\x07'$b
or L_TEMP=$a$'\a'$b
2,521
Posted By RudiC
How about while read PROJ; do PROJ=${PROJ##*/};...
How about while read PROJ; do PROJ=${PROJ##*/}; echo $PROJ; done < $MY_TEMP_RESULT_1 | sort | uniq -d
another_project
dir_1-3-2-1-1
some_project
3,348
Posted By MadeInGermany
You need to specify the character(-set) that is...
You need to specify the character(-set) that is before the beginning of the string.
If there is nothing before - the string is at the beginning of the line - then give ^.
sed...
3,348
Posted By disedorgue
Hi, A possible syntax, but line mustn't begin...
Hi,
A possible syntax, but line mustn't begin with the string to search (not tested):
sed 's/\([[:space:]]\)string1\.string2\.string3@/\1new_string1.new_string2.new_string3@/g'
Regards.
Showing results 1 to 25 of 68

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