Search Results

Search: Posts Made By: frans
9,847
Posted By frans
The simplest i know pidof -x -o $$ $(basename...
The simplest i know
pidof -x -o $$ $(basename "$0") && exit 1
4,854
Posted By frans
something likesed -n '/\<component/,/.*>/p'...
something likesed -n '/\<component/,/.*>/p' infile.xml | grep -E 'version=|description='
15,011
Posted By frans
getting parameters in a function is the same as...
getting parameters in a function is the same as in a script. If you call the script like InsertRecord "$OLD_VAL" "$NEW_VAL" "$DATE"
you can retrieve the values inside the function (as in your...
16,070
Posted By frans
You can simply add html tags in your echo...
You can simply add html tags in your echo statements.
Don't forget to add echo statements for header and footer.
If you use variables for the tags, you can choose between plain text or html by...
9,304
Posted By frans
I'm searching for a similar tool. I found a...
I'm searching for a similar tool.
I found a simple way to print the duplicate file names
#!/bin/bash
FILES=/dev/shm/filelist
find -type f | awk -F'/' '{print $NF}' | sort | uniq -d > $FILES...
2,728
Posted By frans
If they must be exactly the same ...
If they must be exactly the same
systime=2011-05-13:18:45
shubtime=2011-05-13:18:30
if [ "$systime" = "$shubtime" ]
then
echo" OK"
else
echo "NOK"
fi
Or shorter:[ "$systime" =...
6,690
Posted By frans
#!/bin/bash ##!/bin/bash var2="bgroup = set...
#!/bin/bash
##!/bin/bash
var2="bgroup = set bgroup port"
var3="utm = set security utm"
echo "$var2 --> '${var2# = }'"
echo "$var3 --> '${var3# = }'"
# You can also
for V in var2 var3; do
...
51,888
Posted By frans
Could be written (with arithmetic evaluation and...
Could be written (with arithmetic evaluation and array)
#!/usr/bin/bash
parity=(even odd) # parity[0]='even' parity[1]='odd'
read -p "enter a number: " a
echo "the number is ${parity[$((a%2))]}
8,278
Posted By frans
No need to mkdir -p /foo if you already mkdir -p...
No need to mkdir -p /foo if you already mkdir -p /foo/dir1 as the -p option creates parents.

#!/bin/bash
for d1 in boo doo foo; do
for d2 in dir1 dir2; do
mkdir -p /$d1/$d2
...
5,256
Posted By frans
#!/bin/bash while IFS='&' read -a L do ...
#!/bin/bash
while IFS='&' read -a L
do
for i in ${!L[@]}; do
eval "${L[$i]}"
done
for V in poc ooc mjv omj mov ps rel bod oxi ozn lang loc
do
echo -en "$V=${!V}\t"
...
5,492
Posted By frans
If you have GNU date $ D1="5/21/2010 9:14:00...
If you have GNU date
$ D1="5/21/2010 9:14:00 AM"
$ D2="5/24/2010 7:23:00 AM"
$ DM=$((($(date -d "$D2" +%s)-$(date -d "$D1" +%s))/60))
$ printf "%s:%02d\n" $((DM/60)) $((DM%60))
70:09
2,137
Posted By frans
Just an example of how it can be done (first get...
Just an example of how it can be done (first get rid of the GOTO):
#!/bin/bash
while : ; do
echo "SELECT OPTION"
echo "-------------"
echo "1- Create username"
echo "2- Create...
1,449
Posted By frans
Please, use code tags. Somthing like if...
Please, use code tags.
Somthing like
if (($#<2)); then
echo "There must be at least 2 parameters (pattern, file)"
exit 1
fi
Pattern="$1"
shift
Response=$(grep "$Pattern" "$@")
#...
1,079
Posted By frans
Yes I can !
Yes I can !
59,198
Posted By frans
Why store it? (but it's preferable to store the...
Why store it? (but it's preferable to store the date string to avoid calls to date in the iteration.
#!/bin/bash
D=$(date +%d-%m-%Y)
for F in *.*
do
mv $F ${F%.*}-$D.${F##*.}"
done
1,954
Posted By frans
Please, use code tags to make the code more...
Please, use code tags to make the code more readable.
Howto:

Select the text corresponding to code
Click on the 'code' button in the editor's...
2,707
Posted By frans
What's the output of this: #!/bin/bash while...
What's the output of this:
#!/bin/bash
while IFS=':=' read A B C
do
echo "A='$A' B='$B' C='$C'"
done <$INFILE

---------- Post updated at 23:06 ---------- Previous update was at 21:52...
1,664
Posted By frans
egrep: F=570345 echo *${F}* | grep -E...
egrep:
F=570345
echo *${F}* | grep -E '[^0-9]$F[^0-9]'
# ls *${F}* | grep -E '[^0-9]$F[^0-9]' # If the previous doesn't work
1,072
Posted By frans
#!/bin/bash while IFS='<>' read Null Tag Val...
#!/bin/bash
while IFS='<>' read Null Tag Val Null
do
case $Tag in
free-energy)
echo $Val
Pos=0 ;;
position)
((Pos++))
((Pos%2)) && echo -n...
5,258
Posted By frans
Simple while read file do rm -f FolderB/$file...
Simple
while read file
do rm -f FolderB/$file
done < <(ls FolderA)
4,634
Posted By frans
No need to count the lines: while read L do ...
No need to count the lines:
while read L
do
echo "$L"
done <playerlist
Above code reads each line of playerlist and assigns it to the variable L; then prints the variable on screen, until...
3,511
Posted By frans
grep -i 'model name' /proc/cpuinfo | cut -d: -f2...
grep -i 'model name' /proc/cpuinfo | cut -d: -f2 | head -1
1,388
Posted By frans
With the GNU date: LIMIT=$(date -d '-8 days'...
With the GNU date:
LIMIT=$(date -d '-8 days' '+%Y/%m/%d')
while IFS='|'; read D L
do [[ $D > $LIMIT ]] && echo "$D|$L"
done < infile
awk:
awk -F'|' -vD=$(date -d '-8 days' '+%Y/%m/%d') '$1 > D'...
3,911
Posted By frans
sed
sed -e 's/ [^ ]*\.log//g' -e 's/ / /g' -e 's/^ //' file
To modify file in place
sed -i -e 's/ [^ ]*\.log//g' -e 's/ / /g' -e 's/^ //' file
If -i option isn't available, you can redirect outpu to...
7,379
Posted By frans
I wrote a function to handle different cases of...
I wrote a function to handle different cases of pause in shell scripts. You can simplify it for your needs.
pause() { # [1:timeout] [2:prompt]
local P T
[[ $1 =~ ^[0-9]+$ ]] && { T=$1; shift; }...
Showing results 1 to 25 of 53

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