VARIABLE HANDLING in UNIX


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers VARIABLE HANDLING in UNIX
# 1  
Old 05-28-2005
VARIABLE HANDLING in UNIX

Hi All,
Smilie
can anyone throw some light on variable handling in UNIX script??
I want to know about the local variables we declare inside the UNIX script.


e.g.
i=10
OR

cat file1 | while read line
do
echo $line
done

etc.
Does UNIX have any data types
Can some one recomend any link or book for this???
Thanx
VEN.
# 2  
Old 05-28-2005
You could try out the online unix scripting guide. You can find it at

http://www.linuxvoodoo.com/resources...ide/index.html

Another thing, while reading your post you mentioned
Code:
cat file1 | while read line
do
echo $line
done

A better way for the above is
Code:
while read line
do
echo $line
done < file1

The 'cat' in your code is what is termed as an UUOC-useless use of cat.

man cat says..cat - concatenate files and print on the standard output

Anyway that was just an advice.

Vino
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX file handling issue

I have a huge file semicolon( ; ) separated records are Pipe(|) delimited. e.g abc;def;ghi|jkl;mno;pqr|123;456;789 I need to replace the 50th field(semicolon separated) of each record with 9006. The 50th field can have no value e.g. ;; Can someone help me with the appropriate command. (3 Replies)
Discussion started by: Gurkamal83
3 Replies

2. Programming

Please help:program hang stuck there signal handling on POSIX Message Queue UNIX C programming

in a single main() function,so need signal handling. Use Posix Message Queue IPC mechanism , can ignore the priority and other linked list message,to implement the scenario: client:Knock Knock server:who's there client: Eric Server:Eric,Welcome. client:exit all process terminated ... (1 Reply)
Discussion started by: ouou
1 Replies

3. UNIX for Dummies Questions & Answers

File Handling in UNIX

Hi all, I have a requirement here where I am dealing with a dynamic file. Each record in the file can contain anywhere between 1(min) to 42(max) Reject codes. For example I may have one record in the file having 3 reject codes and another record having 5 reject codes. The reject codes will be... (2 Replies)
Discussion started by: sujainarayan
2 Replies

4. Shell Programming and Scripting

Error handling in Unix shell scripting

Hello, I have written a shell script and suppose there is any error in the script. How i can do exception handling in shell script.for example i have below code sqlplus -s <<uid>>/<<pwd>>@<<$ORACLE_SID>> <<EOF > 1_pid1.log set pagesize 0 set feedback off set heading off set linesize 200... (1 Reply)
Discussion started by: rksingh003
1 Replies

5. UNIX for Dummies Questions & Answers

Socket Handling Differences Between Linux & Unix?

Sorry if this is a stupid question! I have been developing a Java application that I am deploying on both Unix and Linux servers, which uses lots of socket handling. When the server side connection is dropped by the server un-gracefully I have been seeing close_waits and null connections. ... (0 Replies)
Discussion started by: Vinnie
0 Replies

6. Shell Programming and Scripting

Help needed in switch case handling in UNIX

Hi, In below code, i am expecting the output has Bye Bye But i am getting has Bye Hi Code: #!/usr/bin/bash var="Hi" cat txt.txt | while read var1 do next="Bye" case $var in Hi) (1 Reply)
Discussion started by: Balamani
1 Replies

7. Shell Programming and Scripting

File handling, getopts command in unix

I need to create a shell script having the menu with few options such as 1. Listing 2. Change permissions 3. Modify Contents 4. Delete Files 5. Exit 1. For 1. Listing: Display a special listing of files showing their date of modification and access time (side by side) along with their... (2 Replies)
Discussion started by: bab123
2 Replies

8. Programming

Handling variable inputs

Hi, Is there any way to handle variable inputs. If an application handles more than one input how to print the input values. Example : ./a.out 1 "hi" 3 ./a.out 1 ./a.out 1 3 4 "hello" output should be: 1 hi 3 1 (1 Reply)
Discussion started by: yhacks
1 Replies

9. UNIX for Dummies Questions & Answers

File handling in UNIX

Hi All, I want to read a file in UNIX line by line. Can u suggest me any command for this? (4 Replies)
Discussion started by: VENC22
4 Replies

10. Shell Programming and Scripting

handling spaces in unix

I am testing a ksh script for email. In the script I receive several parameters. One of them is a subject. The subject may contain spaces. Ex. Test this. When I am running the script on telnet to test, how should the syntax at the command line be written. I have this: ksh ResendE.sh '001111'... (2 Replies)
Discussion started by: supercbw
2 Replies
Login or Register to Ask a Question