Search Results

Search: Posts Made By: mjd_tech
27,412
Posted By mjd_tech
Here's the settings from my .vimrc file set...
Here's the settings from my .vimrc file
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
I think this will do what you want.
4,260
Posted By mjd_tech
Here's another way, using only shell while read...
Here's another way, using only shell
while read line; do
/usr/local/mystro/scripts/mdiags cid reg ${line%|*} ${line#*|}
done < IP
${line%|*} extracts the MAC address
${line#*|} extracts the...
4,811
Posted By mjd_tech
Oops, I forgot to quote ALL the vars... Ksh...
Oops, I forgot to quote ALL the vars...

Ksh version:
#!/bin/ksh
IFS="~"
VAR1="1~2~3~4"

echo "$VAR1" | read a b c d
echo "$a $b $c $d"
echo "$a"

# Result
1 2 3 4
1

Bash / Dash...
25,987
Posted By mjd_tech
Looks like you've got an if statement without...
Looks like you've got an if statement without corresponding fi
4,811
Posted By mjd_tech
You need to quote the ~ in the IFS assignment ...
You need to quote the ~ in the IFS assignment
IFS="~"In Bash or Dash you need to group the commands following the pipe.
#!/bin/sh
IFS="~"
VAR1=1~2~3~4
echo $VAR1 | { read a b c d; echo "$a $b $c...
6,654
Posted By mjd_tech
shell - word splitting - using eval
In POSIX shell, we don't have arrays, but we can iterate over a list like this:

#!/bin/sh
list="Fred Barney Wilma Betty"
for i in $list; do echo $i; done

Fred
Barney
Wilma
Betty
But let's...
23,575
Posted By mjd_tech
Here's a way to do this using only shell with no...
Here's a way to do this using only shell with no external commands.
It's nowhere near the elegance of the other solutions posted here.:o
It's an example of how to use file descriptors to read more...
23,575
Posted By mjd_tech
ripat, I knew there would be a better way,...
ripat,

I knew there would be a better way, most likely awk.
Here, I try to explain how it works...
awk '
NR==FNR {_[NR]=$0}
# NR is total number of lines read in both...
23,575
Posted By mjd_tech
There are probably a million better ways to do...
There are probably a million better ways to do this...
but here goes...
#!/bin/sh
linecount1=$(wc -l file1.txt | cut -d\ -f 1 )
linecount2=$(wc -l file2.txt | cut -d\ -f 1 )
i=1 j=1
while [...
52,301
Posted By mjd_tech
Ah! (light bulb turns on inside head) I get it...
Ah! (light bulb turns on inside head)
I get it now.
I was thinking the "line" variable would hold the last line read.

so with:
while read line ; do some-command ; done < some-file

"read"...
52,301
Posted By mjd_tech
while read loop; scope of variables (shell)
If I set a variable within a while-read loop, sometimes it's local to the loop, sometimes it's global, depending on how the loop is set up. I'm testing this on a Debian Lenny system using both bash...
2
7,810
Posted By mjd_tech
Maybe something like this? result=$(zenity...
Maybe something like this?
result=$(zenity --title "Test Entry Box" --entry --text "Accept default or change value" --entry-text "Default Value")

echo "$result"
-MD
Showing results 1 to 12 of 12

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