Search Results

Search: Posts Made By: frans
9,799
Posted By frans
The simplest i know pidof -x -o $$ $(basename...
The simplest i know
pidof -x -o $$ $(basename "$0") && exit 1
4,819
Posted By frans
something likesed -n '/\<component/,/.*>/p'...
something likesed -n '/\<component/,/.*>/p' infile.xml | grep -E 'version=|description='
14,856
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...
15,979
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,282
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,673
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,612
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,797
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))]}
7,542
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,231
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,445
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,135
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,422
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,066
Posted By frans
Yes I can !
Yes I can !
59,013
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,952
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,669
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,620
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,059
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,179
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,560
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,488
Posted By frans
grep -i 'model name' /proc/cpuinfo | cut -d: -f2...
grep -i 'model name' /proc/cpuinfo | cut -d: -f2 | head -1
1,372
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,858
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,286
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 01:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy