• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

TechLila

Bleeding Edge, Always

  • Home
  • About
  • Contact
  • Deals and Offers
Techlila Logo
Share
Tweet
Share
Pin
2 Shares
Linux File Permissions: the Tutorial
Up Next

Linux File Permissions: the Tutorial

Shell Tips

TechLila Computer Linux

Five Useful Shell – Prompt Tips

Avatar of Rajesh Namase Rajesh Namase
Last updated on: December 4, 2017

Here we are enlightening you with five useful Shell-Prompt tips which definitely will prove to be a boon for you.

1) For a short-cut we always define the alias. But, sometimes, we don’t need that and want the original effect of the command.

For example:

alias ls='ls -la'

Now to restrict the alias effect and see the native command, we can execute it in any of the following three ways:

$ command ls
$ \ls
$ "ls"

2) If you want to check whether alias are assigned to a particular command, you can use the type command with an alias name as follows:

$ type ls

You can also use the unalias command to revert back to the original ‘ls‘ command:

$ unalias ls

This will display the alias name, if the alias is assigned.

3) To open an application from the command line in GNOME, we can use the gnome-open command. For example:

$ gnome-open jash.xls

This will open the file with the application associated with it.

4) Here is a useful way to use the append operator. To append text at the end of a file, we simply use the >> character. But if we want to append text at the beginning of the file, run the following command:

$ echo "hi Nidheeshdas" | cat - file.txt > /tmp/out && mv /tmp/out file.txt

By using this command, the “hi Nidheeshdas” line will be added at the beginning of the file.

5) If you want to find all files with the extension .txt and .jpg, then use the following command:
Shell Tips

$ find . -type f -iname "*.txt" -or -iname "*.jpg"

…where the -type f parameter is used to find files and -or is used for the ‘or’ operation. If you want to exclude hidden files in this ‘find’, then use the ! (not) operator:

$ find . -type f -iname "*.txt" ! -iname ".*"

Variables used by Shell

Here’re some variables and their details that are used by a Shell script.

  • $1, $2 … Positional parameter representing command line argument.
  • $# Number of arguments specified in command line.
  • $0 Name of the executed command.
  • $* Complete set of positional parameters as a single string.
  • “[email protected]” Each quoted string is treated as a separate argument.
  • $? Exit status of the last command.
  • $$ PID of the current Shell.
  • $! PID of last background job.
  • !$ Command line argument of the previous command.
Share
Tweet
Share
Pin
2 Shares

Disclosure: Content published on TechLila is reader-supported. We may receive a commission for purchases made through our affiliate links at no extra cost to you. Read our Disclaimer page to know more about our funding, editorial policies, and ways to support us.

Sharing is Caring

Share
Tweet
Share
Pin
2 Shares
Avatar of Rajesh Namase

Rajesh Namase

Rajesh Namase is a professional blogger and founder of TechLila blog. Also, he's a passionate entrepreneur, internet marketer, and fitness freak.

Category

  • Linux

Tags

Linux Commands, Linux Tutorials

Reader Interactions

What people are saying

  1. Avatar of talatala

    I don’t know C, but I understand the concept of what the assignment is.
    In short, after the program is completed, the professor while testing it, should be able to do the following…

    1.Start the program from a command line on Linux. (We’ll call that session ‘window 1′)
    2.When the program starts, a second window pops up (window 2)
    3.In Window 2, there should be a prompt that has the current name of the directory path that session is in. •In Linux, that info is in the $PWD environment variable. set the prompt environment variable PS1=’$PWD >’
    •That will give you a path that follows the directory your in. I’m also pretty sure your professor will check to see if he CD’s into another directory, will your path stay with him.

    4.From Win2, the user should enter in one of these 6 made up commands.
    These commands are TYPED in Win2, but the output has to go to Win1 (the original window) •Sho (alias for Linux command, ls)
    •2nsa5 (alias for Linux command, cp)
    •2m7i (alias for Linux command, rm)
    •Roo7 (alias for Linux command, cd)
    •Dawir (alias for Linux command, grep)
    •23rid (alias for Linux command, more)

    5.Another command is 2ktob. After the command and a file name is entered, the rest of the output for this should stay on Win2 as the user types text, and what ever name the user has for file name, should be the name used to create a text file. (Don’t call the file ‘filename’)
    Also, be sure to generate an error if there is no file name entered. I’m pretty sure that will be tested.
    6.The final command, bye would close Window2 and end the program.

    The major trick to this project before you even write any code is to find out HOW to enter text in ONE session and have the output in a second session. I suspect her professor has already gone over that (thus the test) so hopefully that’s covered.

    The second trick is to simply substitute the fake commands with the real commands.

    For that (unless directed otherwise by the professor) I would simply use the ‘alias’ command.

    For example:

    Alias sho=ls

    Then when you type sho, linux reads it as ls.

    Embed is into your C code, and you’re set… just direct the output to window 1.
    Etc.e
    .
    Note: we cant use aliasing we must use parsing or something like that in C
    thank u

    Reply

Add Your Comment Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Popular

How to Increase Broadband Speed on Windows

10 Best Android Launchers of 2023

Things to Do After Installing Windows 10 – Windows 10 Tips and Tricks

Top 10 Search Engines You Can Use to Search the Web Privately

55 Interesting Computer Facts That Will Blow Your Mind

What to Look for When Buying a Laptop – A Laptop Buying Guide

Fusion Drive Vs SSD – Things Nobody Tells you About Fusion vs SSD Storage

Useful Tools

• Grammarly – Free Grammar Checker
• SEMrush – The Best SEO Tool Trusted by Experts
• Setapp – One-stop subscription for Mac and iOS

Trending Topics

  • Android
  • Internet
  • iPhone
  • Linux
  • Macintosh
  • Press Releases
  • Security
  • Social Media
  • Technology
  • Windows

Worth Checking

10 Best Sound Equalizers for Windows 10 (2023 Edition!)

14 Best VLC Skins that are Highly Recommended and Free

Footer Logo Footer Text Logo

Footer

About

Hello and welcome to TechLila, the famous technology blog where you can find resourceful articles for mastering the basics and beyond.

At TechLila, our main goal is to provide unique information, such as quality tips and tricks, tutorials, how-to guides on Windows, Macintosh, Linux, Android, iPhone, Security and a few miscellaneous sub-topics such as reviews.

Links

  • About
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms

Follow

Custom Theme Using Genesis Framework

Cloud hosting by Cloudways

Language

© Copyright  2012–2023 TechLila. All Rights Reserved.