InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

Menu
  • Home
  • Sitemap

Python Programming Language Best Tutorials and Code Examples

Learn Python Right Now!
Home
Bash
Saving Output to Other Files in bash
Bash

Saving Output to Other Files in bash

InfinityCoder January 12, 2017

You want to save the output with a redirect to elsewhere in the filesystem, not in the current directory.

Use more of a pathname when you redirect the output.

1
$ echo some more data > /tmp/echo.out

or:

1
$ echo some more data > ../../over.here

The filename that appears after the redirection character (the >) is actually a pathname.
If it begins with no other qualifiers, the file will be placed in the current directory.

If that filename begins with a slash (/) then this is an absolute pathname, and will be placed where it specifies in the filesystem hierarchy (i.e., tree) beginning at the root (provided all the intermediary directories exist and have permissions that allow you to traverse them).

We used /tmp since it is a well-known, universally available scratch directory on virtually all Unix systems.

The shell, in this example, will create the file named echo.out in the /tmp directory.
Our second example, placing the output into ../../over.here, uses a relative pathname, and the .. is the specially-named directory inside every directory that refers to the parent directory.

So each reference to .. moves up a level in the filesystem tree (toward the root, not what we usually mean by up in a tree).

The point here is that we can redirect our output, if we want, into a file that is far away from where we are running the command.

Share
Tweet
Email
Prev Article
Next Article

Related Articles

Redirecting Output for the Life of a Script in bash
You’d like to redirect output for an entire script and …

Redirecting Output for the Life of a Script in bash

Checking a tar Archive for Unique Directories in bash
You want to untar an archive, but you want to …

Checking a tar Archive for Unique Directories in bash

About The Author

InfinityCoder
InfinityCoder

Leave a Reply

Cancel reply

Recent Tutorials InfinityQuest

  • Adding New Features to bash Using Loadable Built-ins in bash
    Adding New Features to bash Using Loadable …
    June 27, 2017 0
  • Getting to the Bottom of Things in bash
    Getting to the Bottom of Things in …
    June 27, 2017 0

Recent Comments

  • fer on Turning a Dictionary into XML in Python
  • mahesh on Turning a Dictionary into XML in Python

Categories

  • Bash
  • PHP
  • Python
  • Uncategorized

InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

About Us

Start learning your desired programming language with InfinityQuest.com.

On our website you can access any tutorial that you want with video and code examples.

We are very happy and honored that InfinityQuest.com has been listed as a recommended learning website for students.

Popular Tags

binary data python CIDR convert string into datetime python create xml from dict python dictionary into xml python how to create xml with dict in Python how to write binary data in Python IP Address read binary data python tutorial string as date object python string to datetime python

Archives

  • June 2017
  • April 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
Copyright © 2021 InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more
Programming Tutorials | Sitemap