Search Results

Search: Posts Made By: gary_w
Forum: What is on Your Mind? 04-15-2013
5,650
Posted By gary_w
Rogue! Different every time you play. ...
Rogue! Different every time you play.

For the uninitiated:
http://en.wikipedia.org/wiki/Rogue_(video_game)
GameFAQs: Rogue (UNIX) FAQ by MToy...
532
Posted By gary_w
Stating what database and shell you are using...
Stating what database and shell you are using would help, but since that info is not here...

Here's a couple of ways. First, try putting put a TRIM( ) function call (or your system's equivalent)...
1,399
Posted By gary_w
If sed chokes on it perl may be a better choice.
If sed chokes on it perl may be a better choice.
1,037
Posted By gary_w
Let me google that for you...
Let me google that for you (http://lmgtfy.com/?q=unix+command+practice)
;-)
1,175
Posted By gary_w
Quick, post this in the homework forum before you...
Quick, post this in the homework forum before you get flamed!
Senior Advisor - https://www.unix.com (https://www.unix.com/homework-coursework-questions/)

Read and heed:...
1,015
Posted By gary_w
You are running the hostname command twice: if...
You are running the hostname command twice:
if [[ `hostname` =~ "t70cra2[01-40]" ]] || [[ `hostname` =~ "t70c6n2[01-28]" ]]; then
Instead, for efficiency, call it once and save it into a variable...
2,550
Posted By gary_w
Please show a sample line and what the output...
Please show a sample line and what the output should look like.
2,061
Posted By gary_w
An attempt to further explain the regular...
An attempt to further explain the regular expression, with an ulterior motive of setting up for a question.

Given:
sed 's/^\([^:]*\):[^:]:/\1::/'search for a pattern in the string matching:
^ ...
595
Posted By gary_w
What about paste? $ paste abc xyz a 1 ...
What about paste?
$ paste abc xyz
a 1
b 2
c 3
$
Forum: Linux 02-27-2013
1,538
Posted By gary_w
FYI blast from the past In older shells the...
FYI blast from the past
In older shells the circumflex was used before the pipe symbol to join STDOUT of one command to STDIN of another:

$ sh
$ who^wc -l
8
$
1,482
Posted By gary_w
Try this
$ cat x
#!/bin/ksh

## The command in $() returns COUNT=<nbr> which is then eval'd to create
## and set a shell variable called COUNT. There is a carriage return after the
## set heading off;...
1,091
Posted By gary_w
https://www.unix.com/shell-programming-scripting/85...
https://www.unix.com/shell-programming-scripting/85606-print-previous-current-next-line-using-sed.html


sed -ne '/^reason code/{x;1!p;g;$!N;p;D;}' -e h x.dat | \
mailx -r "Reason_code_checker"...
631
Posted By gary_w
sed 's/\(.\{78\}\)_\(.*\)/\1\2/' x.dat ...
sed 's/\(.\{78\}\)_\(.*\)/\1\2/' x.dat
N-{[3,4-dihydroxy-5-(hydroxymethyl)oxolan-2-yl]amino}(2-hydroxyphenyl)carboxamide


Search for 78 instances of any character (and remember it), followed by...
892
Posted By gary_w
sed -n 's/\(.*\)\/bin.*/\1/p' This looks a tad...
sed -n 's/\(.*\)\/bin.*/\1/p'
This looks a tad cleaner:
sed -n 's#\(.*\)/bin.*#\1#p'
703
Posted By gary_w
Be careful with eval. Could be dangerous if the...
Be careful with eval. Could be dangerous if the pics variable is built from user input. Try this:

pics="[a-z]*.{bmp,png,gif,jpeg,jpg};who"
eval ls $pics
1,648
Posted By gary_w
Note that RudiC's method counts the word if it is...
Note that RudiC's method counts the word if it is part of another word. I do not know if this is the desired result as the original spec did not get that detailed. Just sayin'.
1,648
Posted By gary_w
#!/bin/ksh FILE1=x1.dat FILE2=x2.dat ...
#!/bin/ksh

FILE1=x1.dat
FILE2=x2.dat

while read word
do
# -w option to grep for searching on a word boundary.
count=$( grep -wc "$word" $FILE2 )
printf "%s: %d\n" "$word" $count...
2,074
Posted By gary_w
Keep everything before the first space, then add...
Keep everything before the first space, then add on a TAB and a string:
sed 's/^\([^ ]*\) .*/\1<TAB-see note below>AT50/' filenameNote: replace "<TAB-see note below>" with a Tab character. To...
973
Posted By gary_w
Is there no tell-tale text that would indicate a...
Is there no tell-tale text that would indicate a line is really a continuation of the previous line? Maybe post an example or two.
973
Posted By gary_w
The percent sign as you described is shorthand...
The percent sign as you described is shorthand meaning all lines in the file. You could replace it with a 1,5 for example to restrict the following search/replace to that range of lines.

Search...
2,145
Posted By gary_w
Define the variables as floats and use parens...
Define the variables as floats and use parens instead of square brackets for a numeric comparison.
$ cat x
#!/bin/zsh

typeset -F a=1.4
typeset -F b=1.7

printf "START - a: %0.2f, b:...
3,691
Posted By gary_w
I see your sed, and raise you a find. This will...
I see your sed, and raise you a find. This will add the contents of "/path/to/file.addition" to the top of every file found.
find . -name /files/to/edit -exec ksh -c 'cat /path/to/file.addition $1...
3,691
Posted By gary_w
Right-click in PuTTY to paste. Make sure you are...
Right-click in PuTTY to paste. Make sure you are in an input mode in vi first.

Actually, put the code you need to add in its own file and add it to each site file using :r in vi to read it in...
1,934
Posted By gary_w
#!/bin/ksh while IFS=',' read part1 part2;...
#!/bin/ksh

while IFS=',' read part1 part2; do
printf "%s,%s %s\n" $part1 $part2 $part1
printf "%s,%s %s\n" $part1 $part2 $part2
done < filename

exit 0
546
Posted By gary_w
Another way using sed. Match any number of...
Another way using sed.

Match any number of numbers between single quotes:
sed "s/'[0-9]*'/'1100000001'/" fileor match 10 numbers in a row:
sed 's/[0-9]\{10\}/1100000001/' file
Showing results 1 to 25 of 433

 

Featured Tech Videos

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