Logo
  • Home
  • About
  • Services
  • Blogs
  • Career
  • Contact
Logo

The UK's #1 Software Development Company. PodTech IO builds custom software solutions for businesses. Call today for a free consultation

  • Address

    4th Floor, 4 Tabernacle Street London EC2A 4LU
  • Email

    info@podtech.com
  • Contact

    +44 (0) 20 8720 6583

Shell, KSH Read Variables

  • Home
  • Shell, KSH Read Variables
  • By podtech
  • In UNIX

Shell, KSH Read Variables

Read in a Variable

From a user we read with: read var. Then the users can type something in. One should first print something like:
[bash]
print -n “Enter your favorite haircolor: “;
read var;
print “”.
[/bash]

The -n suppresses the newline sign.
Read into a File Line for Line

To get each line of a file into a variable iteratively do:
[bash]
{ while read myline;do
# process $myline
done } < filename
[/bash]

To catch the output of a pipeline each line at a time in a variable use:

[bash]
last | sort | {
while read myline;do
# commands
done }
[/bash]

Special Variables

$# Number of arguments on commandline.
$? Exit status of last command.
$$ Process id of current program.
$! Process id of last backgroundjob or background function.
$0 Program name including the path if started from another directory.
$1..n Commandline arguments, each at a time.
$* All commandline arguments in one string.

KSHKSH Read VariablesRead VariablesShellShell Read Variables
Pass Parameters to Perl Script
Select next available ID

Recent Posts

  • DevOps as a Software Development Methodology
  • How Does Spiral Software Development Methodology Work?
  • Waterfall Software Development Methodology And When To Use It
  • What Exactly Is Lean Software Development Methodology?
  • What is Kanban and How Does It Work?

PodTech IO

The UK's #1 Software Development Company. PodTech IO builds custom software solutions for businesses. Call today for a free consultation

Company

  • About
  • Services
  • Contact
  • Blogs
  • Career

Terms

  • Terms & Conditions
  • Privacy Policy

Contact Us

  • ADDRESS

    Headquarter: Tabernacle Street London India: Vi john Tower, Gurgaon, Haryana
  • EMAIL

    info@podtech.com
  • CONTACT

    +44 (0) 20 8720 6583

Copyright ©2023 PodTech IO. All Rights Reserved

Logo