Solved

regarding unix commands

Posted on 2004-08-08
6
343 Views
Last Modified: 2013-12-26
hi,
  i have queries on some commands.I have listed it below
1. I want to know the Command to know the version of unix and company which developed unix?
2. In wc command there are two optional arg,c- counts the number of bytes m-counts the number  
    of characters.What's the difference between the two option
    I tested with a file test.txt with contents 123\n123\n1
    when i do wc -c  a.txt and wc -m a.txt i get 9 as answer.
3. To find the files in my directory which start with letter 'a' i did the following unix command
    ls -la | grep a* .Im not getting the output.How to do it? * means zero or more characters.
4. Im using a telnet to connect to a remote machine.When i give lp command will the printout goes to
    the printer connected to remote machine or printer connected to the local machine.

 
0
Comment
Question by:pigeon7778
  • 3
  • 2
6 Comments
 

Author Comment

by:pigeon7778
ID: 11746221
I forgot to add one more question to my previous msg.
5. Im giving sh <script name> to run a script.i gave man sh and i saw sh means bourne shell.
   But when i give ps command my shell name shown as ksh.Is my script run by bourne shell or
   kshell.If i change the permission mode of my script as executable and when i run it without
   giving  sh before it what shell it will take? korn or bourne shell.
0
 
LVL 20

Expert Comment

by:tfewster
ID: 11746537
0
 
LVL 23

Accepted Solution

by:
brettmjohnson earned 20 total points
ID: 11747170
1. 'uname -srv'

2. If the current locale support multibyte characters (Unicode, or LMBCS, etc),
then sizeof(character) != sizeof(byte) and a file may have fewer characters than
it has bytes.

3.  Why not just use the command 'ls -la  a*'  ?
There are several things wrong with your example command 'ls -la | grep a*'
The shell performs filename expansion of parameters before running the program
receiving the filenames, so grep will never see 'a*' as a regular expression.  It will
see instead all the filenames begining with 'a' as its arguments.  The other gross
error is the filename globbing rules are very different than the full regular expressions
supported by grep (even though they share some characters).

4. When you telnet into another machine, your local machine performs as little
more than a dumb terminal.  Your keystrokes are transmitted to the remote host,
and characters appearing on the console of the remote host are transmitted back
to your local machine for display.  When you enter the command 'ls', does it show
the files on the remote host or the local host?  Why would 'lp' be any different?

5. So many shells now have Bourne shell emulation that few Unix systems actually
ship with a true Bourne shell any more.   You can explicitly specify which shell
will be used to execute a script with a "sh-bang" line as the first line of the script:
#!/bin/sh
#!/bin/ksh
#!/bin/bash
#!/bin/csh
etc.
If a shell script lacks a sh-bang line, it executes in your default login shell.  For
more information on shells see:  http://helpme.scudc.scu.edu/shells.html







0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:pigeon7778
ID: 11751970
If i give ps command the below results appear
PID TTY       TIME COMMAND
  4359 pts/ta    0:00 ksh
  4439 pts/ta    0:00 ps
  4358 pts/ta    0:00 telnetd
so ksh is the parent shell.If i dont give anything mentions the shell to use(#!/bin/csh) in my script code "a.sh"  and if i give sh a.sh which shell will execute the script.Is ksh executes the script?
0
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 11753738
It appears that ksh is your current shell, quite probably your login shell.
If you type 'sh a.sh', it will execute the first exectuable program named 'sh'
found on your path.  You can find out which that is by running the command,
'which sh'

0
 

Author Comment

by:pigeon7778
ID: 11759728
a.sh
***
echo `which sh`
echo "hello world"

the script displays
/usr/bin/sh
hello world
Does it mean the default shell is posix shell
                       
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now