Search Results

Search: Posts Made By: gary_w
Forum: What is on Your Mind? 04-14-2013
13,878
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...
982
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)...
105,963
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,719
Posted By gary_w
Let me google that for you...
Let me google that for you (http://lmgtfy.com/?q=unix+command+practice)
;-)
1,644
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:...
2,294
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...
5,687
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.
3,547
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:
^ ...
978
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
2,991
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
$
2,769
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;...
2,095
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"...
1,038
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...
2,068
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'
1,350
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
4,276
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'.
4,276
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...
5,737
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...
2,461
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.
2,461
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...
5,328
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:...
6,897
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...
6,897
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...
5,101
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
1,126
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

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