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
Solved

regarding unix commands

Posted on 2004-08-08
6
345 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Smart Camera scanning and reading information 3 113
sum13 challenge 24 123
MaxSpan challenge 9 106
"Black Box" Testing of Control System Software 2 70
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

837 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