Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

regarding unix commands

Posted on 2004-08-08
6
Medium Priority
?
351 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 23

Accepted Solution

by:
brettmjohnson earned 80 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

564 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