All Questions
19
questions
1
vote
1
answer
68
views
Why does enclosing a command in double quotes affect aliases?
I have an alias rm='/bin/rm -i' and I know that if I type "rm" filename in the command line, the alias will be ignored somehow and the normal rm command without the -i flag will be called, ...
3
votes
1
answer
402
views
Why is "${1-"$var"}" (option 6 down below) not mentioned in POSIX?
The only reference I could find in the spec is this:
It would be desirable to include the statement "The characters from an enclosed "${" to the matching '}' shall not be affected by ...
1
vote
1
answer
282
views
UNIX KSH - Using double quotes or no quotes when assigning strings with wildcard to a variable?
I am new to UNIX and currently working on a shell script where I will be receiving files with names such as abc_123_date.zip so the file names will be abc_123_12312005. Instead of hardcoding abc_123_*....
5
votes
3
answers
3k
views
quotes inside backticks inside quotes in ksh
I'm trying to get the file of the current date with the following command in HP-UX Unix:
$ ls -lrt ABC.LOG* |grep "`date +"%b %d"`"
But, it's giving me the error:
ksh: : cannot execute
grep: can't ...
1
vote
2
answers
32k
views
How to compare strings in ksh
I want to check the result of a job and execute an action on FAILED.
First: I grep the last word of the line in my application logfile (for the recent processed file ($processedfilename)):
check1=$(...
1
vote
1
answer
1k
views
How to escape a range of wildcards in unix shell script?
I need to execute the following Oracle SQL in unix crontab. The query is as follows:
select count(*)
from tbaadm.htd
where cust_id is not null and
pstd_flg = 'Y' and
del_flg = 'N' and
tran_date = (...
1
vote
2
answers
1k
views
Unable to store ascii value in a variable
I am trying to convert hex to decimal to ascii and store it in a variable.
I am using the following code.
HEX=30
DEC=`printf "%d\n" 0x${HEX}`
echo "$DEC"
ASC=`printf \\$(printf '%03o' $DEC)`
echo "$...
1
vote
1
answer
3k
views
ksh "<<EOF" script to change user
In the simplest form I am puzzled why this script does not work as expected as a here script changing users with su - user <<EOF.
su - db2prd<<EOF
PARMDATE=1111111
echo parmdate
echo $...
1
vote
1
answer
2k
views
Remote ssh command not sending echo variable from a ksh script on AIX
I'm need to get the value of a variable from a remote host in a script using SSH and have to source an environment file first that does a shift at the end of its run.
The command works locally and I ...
2
votes
2
answers
732
views
Meaning of \ before environment variable
In ksh on an old Solaris box I used:
export PS1="$PWD $"
to set the prompt to the current directory. It works great until you cd elsewhere, then you see that it's not evaluating PWD each time. I ...
1
vote
1
answer
70
views
Problematic quotations
#!/bin/ksh
typeset FILE_SIZE1=$(stat -f '%z' test.txt);
typeset -r BK_STATARGS="-f '%z'"
typeset FILE_SIZE2=$(stat ${BK_STATARGS} test.txt);
echo without arg var ${FILE_SIZE1}
echo with arg var... ${...
1
vote
3
answers
1k
views
Quoting in command substitution
The command
pdftk FileOne.pdf "File two.pdf" output Combined.pdf
works as expected, merging PDF's One and Two. However, if I put the filenames in a file
FileOne.pdf
"File Two.pdf"
and ...
8
votes
4
answers
49k
views
using awk to split a line on single spaces not multiples
I'm trying to split a line that I have no control over the format of. If parameter 7 and 8 are missing which is possible they will be replaced by a space so I would end up with,
field1 field2 field3 ...
2
votes
2
answers
137
views
Awk not rendering any result
My goal is to get the file created in the current month in a directory.
It seems that the command is correct but not rendering any result:
Date=`date '+%b'`
echo $Date
Oct
ls -l | awk -v d="$Date" ...
10
votes
2
answers
24k
views
How do I escape a sub-directory name with an ampersand in it?
Running a kornshell and trying to traverse a directory tree.
Want to cd to a sub-directory named as follows:
-3ab_&_-3dc.img
My question is HOW do I need to escape the ampersand in this name?
I'...