Search Results

Search: Posts Made By: lumix
6,980
Posted By lumix
can't redirect stderr in bash
Consider:

#!/bin/sh
#this is a shell script in sh (bourne)
grep missingfile 2>errout.txt

It works from the command line, but keeps producing errors from the script. So how do I redirect in a...
18,693
Posted By lumix
That's what I was hoping to avoid
That's what I was hoping to avoid
5,994
Posted By lumix
Hmm, how do I create a regular expression for NOT...
Hmm, how do I create a regular expression for NOT [a-z]? In Bourne, [^a-z] gave me an error message:

expr: unmatched [ or [^

The ultimate goal is to test that $x is one character, no more no...
5,994
Posted By lumix
Thanks. I'll try that
Thanks. I'll try that
5,994
Posted By lumix
A way to use test for "$x" = [a-z] (regex)
In bourne, I was hoping to do:

if test "$x" = [a-z]

but even when x equals "q" (not with quotes) test returns 1.

Is there a way to do this?
9,803
Posted By lumix
Ah! Thanks. I must also learn to appreciate the...
Ah! Thanks. I must also learn to appreciate the subtle differences between shells.
9,803
Posted By lumix
Another newb question: how to use test for zero-length string ?
Assume $x equals "".

If I try:

if test -n $x

I get the "Expression syntax" error.

It works in Linux but not in unix bash. In unix bourne I get "test: argument expected"
18,693
Posted By lumix
sed on an environment variable ?
Can I sed on an environment variable, even if I don't need to actually change said (hah, hah) variable? Something like:

sed s/xyz/abc/g $myvar

Then if I did need to change $myvar I could maybe...
95,603
Posted By lumix
I really have to learn to phrase more carefully. ...
I really have to learn to phrase more carefully. I didn't mean to imply error output, but really just the FYI kind of messages that might complement the actual work or output of a tool. Something...
95,603
Posted By lumix
execute a command silently or quietly within a shell
How do I suspend output of commands and tools that sometimes utter unwanted output? I know that I can always pipe to null or some such thing, but is there a simpler more elegant (i.e. accepted)...
9,488
Posted By lumix
How to remove all matches in a string with sed
if I have "abxcdxefx" and want to remove the x's with sed, how can I do this?

Thanks.

WHOOPS:

Just remembered:

echo "abxcdxefx" | sed s/x//g

Thanks for reading, though.
3,494
Posted By lumix
I had a feeling it might require case. Thank you...
I had a feeling it might require case. Thank you so much.
6,729
Posted By lumix
Thanks for the reply. I think I may have done a...
Thanks for the reply. I think I may have done a lousy job of articulating my objective though. I'm looking to test for the presence of a non-numeric character; the above will produce an error. ...
3,494
Posted By lumix
Bourne: search for a non-numeric character in $VAR
if $1 = "123x456", how can I test for the non-numeric character 'x' in that string. I've tried expr with "[^0-9]" but it did not find the x. Any ideas? Can this perhaps be done with sed?

Thanks.
6,729
Posted By lumix
pattern matching in an if-then
I'm having trouble getting my syntax right here; I want to test the value of $1 and return true if it is between 0 and 9. I've tried many combinations including

if [ $1 -eq [0-9] ]

but none...
Showing results 1 to 15 of 15

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