Solved

regarding unix commands

Posted on 2004-08-08
6
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 21

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
Independent Software Vendors: 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 102
move a line in eclipse 3 110
has77  challenge 9 99
Execute multiple curl cmds with sleep and send output to file 10 115
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 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