Create new folder and text file the same time in one line


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 1 Week Ago
Create new folder and text file the same time in one line

Is it possible to create new folder and write a new text file in the folder while the current position is outside the new folder? in one line

Code:
mkdir folder | echo "hello test"> folder/test.txt

not work.
# 2  
Old 1 Week Ago
The pipeline | is for conveying one process' stdout to another process' stdin. Neither does mkdir print anything to stdout, nor does echo read from stdin. So - above pipe is pointless. Try
Code:
mkdir -p folder && echo "hello test"> folder/test.txt

echo only if mkdir succeeds.
This User Gave Thanks to RudiC For This Post:
cmdcmd (1 Week Ago)
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
How to get script to create a new file that lists folder content sorted by size? Braveheart UNIX for Beginners Questions & Answers 4 11-27-2016 09:20 AM
awk to extract digit in line of text and create link cmccabe Shell Programming and Scripting 8 10-29-2016 02:21 PM
Create new file when time change apenkov Shell Programming and Scripting 6 04-24-2013 11:12 AM
How to create a shell script to read a foldername from a text file and go to the folder? pm1504 Shell Programming and Scripting 7 01-28-2013 01:10 AM
Script to create folder, copy file, and send email on success minnino Shell Programming and Scripting 4 10-19-2012 01:24 PM
Compare text file and a folder arijitsaha Shell Programming and Scripting 12 06-11-2012 07:40 AM
Script to create a text file whose content is the text of another files tenteyu Shell Programming and Scripting 1 03-22-2012 09:05 PM
Last modified time of the folder is changing when I view the file inside the directory IND123 Shell Programming and Scripting 2 11-26-2010 04:21 AM
How to create executable file just like in folder /bin? 14th Shell Programming and Scripting 1 11-24-2010 08:28 PM
File in a folder and loop until time RubinPat Shell Programming and Scripting 8 05-26-2010 10:43 AM
Create multiple text file from a single text file on AIX lodhi1978 Shell Programming and Scripting 11 11-19-2009 12:14 AM
how to create folder and sub-folder in UNIX ? suigion Shell Programming and Scripting 2 07-20-2009 02:15 AM
how do you parse 1 line at a time of file1 ie. line(n) each line into new file web_developer UNIX for Advanced & Expert Users 4 06-28-2009 12:07 PM
time stamp of file create nhatch UNIX for Dummies Questions & Answers 7 06-14-2004 10:32 AM
grep multiple text files in folder into 1 text file? coppertone UNIX for Dummies Questions & Answers 7 08-23-2002 02:50 PM