[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Linux: Create file with .sh script containing username

Posted on 2011-10-12
2
Medium Priority
?
394 Views
Last Modified: 2012-05-12
I want a .sh script that will create a new file named "me.txt" and that new file should contain the username of the user who ran the script.
0
Comment
Question by:hankknight
  • 2
2 Comments
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 36959752
Try something like in this example

#!/bin/bash
echo "Testing" > "$USER".txt

Open in new window

0
 
LVL 13

Accepted Solution

by:
Hugh McCurdy earned 2000 total points
ID: 36959757
Wait, you want the file to contain the user name.  OK try this

#!/bin/bash
echo "My user name is $USER" > me.txt

Open in new window

0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Fine Tune your automatic Updates for Ubuntu / Debian
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month20 days, 7 hours left to enroll

867 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