I'm new to unix and the command line and am trying to learn different commands. I have a file (teledir.txt) that contains a name and phone number for 3 different people. I am writing a script that is to take two positional parameters and I typed out how it should behave:
I declared two variables: name=$1 and number=$2. But I'm lost on what command to use in the script to see if the name and/or number exists in the other file.
Hi All,
Has been a while since I was last on, so I hope everyone has been doing fine. ;)
Would like to know if the below IF statement syntax is correct for a ksh environment. It's been pushed into live as someone had deleted the development copy(!); not withstanding that, the statement now... (3 Replies)
Hi,
Can you please help me with this one: I write an "if" statement, something like this:
if
then
echo "big file"
else
echo "normal file"
and I get an error: `'then is not expected
Thanks in advance (6 Replies)
Hi, can someone please tell me what is wrong with this code? I just want it to check if the file size is greater than 2000kb.
if
Thanks!
---------- Post updated at 09:23 PM ---------- Previous update was at 09:21 PM ----------
I should probably post the full code:
#!/bin/sh... (9 Replies)
I'm working on a function in a shell script I'm writing that will eventually take in and print out a list of vendor names and aliases (for my work) Here's the function in question:
addvendorandalias ()
{
echo
echo -n 'Would you like to create a new vendor list (y or n)? '
read answer... (3 Replies)
It saves me lot of typing and space/lines when I do not use full 'if' keyword and construct, instead use ..
&& <statement> || <statement>
that perfectly replaces..
if ; then
<statement>
else
<statement>
fi
Can I use following syntax when I want to add multiple statements under 'if'... (4 Replies)
Hi,
Is there a way to compare the value in if condition with a list of values.
eg . if ]
then
echo "it's a mammal"
else
echo "its not"
fi
Thanks! (8 Replies)
Hi
Can you please tell me what is wrong with this line:
if && ]; then
basically i want to check if x = 12 and F (Filename) end with 'g'. But it is throwing syntax error. (7 Replies)
I am getting the following error when I am running a script in ksh when trying to execute an if statement comparing two numerical values
tstmb.sh: 1.5321e+08: 0403-057 Syntax error
Below is my code snippet.
#!/bin/ksh
set -x
TODAY=$(date +%y%m%d)
for file in $(ls -rt *.log | tail... (11 Replies)
I want to make the file test condition a variable ($Prmshn in code below).
My goal is to use something like the first three unsuccessful if statetments since the 'if
#!/bin/ksh
test_input()
{
Prmshn=${1}
InFLNm=${2}
ifReq="-$Prmshn $InFLNm"
#the following three if statments fail:
#if ] ;... (10 Replies)
Hi folks,
I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex.
I have a bunch of update statements with all columns in a file which I need to convert into insert statements.
UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies
LEARN ABOUT OSF1
unifdef
unifdef(1) General Commands Manual unifdef(1)NAME
unifdef - Removes #ifdefed lines
SYNOPSIS
unifdef [-tlc] [-Dsymbol] [-idsymbol] [-iusymbol] [file] [-Usymbol]
The unifdef command partially simulates the behavior of the C preprocessor in processing #ifdef conditionals.
OPTIONS
Complements the action of unifdef; retains lines that would normally be removed and removes lines that would normally be retained. Speci-
fies symbol as a defined #ifdef symbol. Specifies defined lines inside certain #ifdefs to be ignored but copied out. Specifies undefined
lines inside certain #ifdefs to be ignored and not copied out. Replaces removed lines with blank lines instead of deleting them. Pro-
cesses plain text (rather than C code) input. The unifdef command does not try to recognize comments, single quotes, and double quotes.
Specifies symbol as an undefined #ifdef symbol.
DESCRIPTION
The unifdef command recognizes nested #ifdefs, comments, single and double quotes of C syntax so that it can function correctly, but does
not include files or interpret macros. The unifdef command recognizes, but does not remove comments.
The unifdef command takes its input from stdin if no file argument is given, and copies its output to stdout.
You specify the symbols you want defined with -Dsymbol or undefined with -Usymbol and the lines inside those #ifdefs are copied to the out-
put or removed, as appropriate. The #ifdef, #ifndef, #else, #elif, and endif lines associated with symbol are also removed. The #ifdefs
involving unspecified symbols are untouched and copied out along with their associated #ifdef, #else, elif, and #endif lines. If the same
symbol appears in more than one argument, only the first occurrence is significant. For instance, if an #ifdef X occurs nested inside
another #ifdef X, the inside #ifdef is considered an unrecognized symbol.
If you use #ifdefs to delimit non-C lines, such as comments or unfinished code, it is necessary to specify which symbols are to be used for
that purpose. Otherwise, the unifdef command tries to parse for quotes and comments in those #ifdef lines.
Keywords
The following keywords can be used with the unifdef command:
ifdef ifndef else endif elif
The unifdef command uses the elif keyword as follows. (Note that "Understood" means unifdef knows how to convert elif to if.) Understood
Not understood Not understood
For example:
# ifdef X x # elif defined (Y) y # elif defined (A) || defined (B) a # else default # endif
The following list shows the results of using the elif keyword with variables:
-DX x
-UX # if defined (Y) y # elif defined (A) || defined (B) a # else default # endif -UX -DY y
-UY -UX # if defined (Y) y # elif defined (A) || defined (B) a # else default # endif
-UY -UX -DA # if defined (Y) y # elif defined (A) || defined (B) a # else default # endif
NOTES
The unifdef command cannot process cpp constructs such as:
#if defined(X) || defined(Y)
DIAGNOSTICS
The unifdef command can fail for several reasons: a premature end of file, or an inappropriate else, elif, or endif.
EXIT STATUS
Exit status is 0 if output is an exact copy of input, 1 if not, 2 if the unifdef command fails.
EXAMPLES
The following command line causes the unifdef command to read the file original.c and remove the #ifdef A lines. It then removes every-
thing following an #elif/#else associated with the #ifdef A down to the #endif: unifdef -DA original.c > modified.c The following command
line causes the unifdef command to read the file original.c, and remove the #ifdef A down to either its associated #elif/#else, or its
associated #endif: unifdef -UA original.c > modified.c
In the case of the #elif, the #elif is replaced with #if. In the case of #else, the #else is deleted along with its associated
#endif.
SEE ALSO
Commands: diff(1)unifdef(1)