# touch command

**URL:** <https://community.unix.com/t/touch-command/257318>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [January 11, 2010, 12:46pm UTC](https://community.unix.com/t/touch-command/257318 "2010-01-11T12:46:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![funyotros](https://community.unix.com/letter_avatar/funyotros/32/6_22734026db12803ebb3e059622ac3534.png) [@funyotros](https://community.unix.com/u/funyotros)\
**Post date:** [January 11, 2010, 12:46pm UTC](https://community.unix.com/t/touch-command/257318/1 "2010-01-11T12:46:47Z")

</div>

Is there a way to do...

```nohighlight
touch ./config/newdir/newfile

```

if neither newdir and newfile exists?

man touch tells me there's not (?)  
Is out there another tool to do that?  
Thx in advance! :b:

---

<div class="post-metadata">

**Author:** ![Scott](https://community.unix.com/letter_avatar/scott/32/6_22734026db12803ebb3e059622ac3534.png) [@Scott](https://community.unix.com/u/Scott)\
**Post date:** [January 11, 2010, 2:05pm UTC](https://community.unix.com/t/touch-command/257318/2 "2010-01-11T14:05:48Z")

</div>

Hi.

What about:

```nohighlight
mkdir -p ./config/newdir && touch newfile

```

Or

```nohighlight
(mkdir -p ./config/newdir && touch newfile) 2>/dev/null

```

---

<div class="post-metadata">

**Author:** ![tlarkin](https://community.unix.com/letter_avatar/tlarkin/32/6_22734026db12803ebb3e059622ac3534.png) [@tlarkin](https://community.unix.com/u/tlarkin)\
**Post date:** [January 11, 2010, 2:54pm UTC](https://community.unix.com/t/touch-command/257318/3 "2010-01-11T14:54:06Z")

</div>

Depends on what you are doing....Often times I will echo a command out to a text file and use \> or \>\> which should create the full path to the file.

---

<div class="post-metadata">

**Author:** ![Franklin52](https://community.unix.com/user_avatar/community.unix.com/franklin52/32/500_2.png) [@Franklin52](https://community.unix.com/u/Franklin52)\
**Post date:** [January 11, 2010, 3:02pm UTC](https://community.unix.com/t/touch-command/257318/4 "2010-01-11T15:02:31Z")

</div>

> [@tlarkin](#):
>
> Depends on what you are doing....Often times I will echo a command out to a text file and use \> or \>\> which should create the full path to the file.

Even to a file in a not existing directory?

---

<div class="post-metadata">

**Author:** ![tlarkin](https://community.unix.com/letter_avatar/tlarkin/32/6_22734026db12803ebb3e059622ac3534.png) [@tlarkin](https://community.unix.com/u/tlarkin)\
**Post date:** [January 11, 2010, 3:36pm UTC](https://community.unix.com/t/touch-command/257318/5 "2010-01-11T15:36:16Z")

</div>

> [@franklin52](#):
>
> Even to a file in a not existing directory?

it a non existent directory, nope, sorry read that wrong

---

<div class="post-metadata">

**Author:** ![EAGL](https://community.unix.com/letter_avatar/eagl/32/6_22734026db12803ebb3e059622ac3534.png) [@EAGL](https://community.unix.com/u/EAGL)\
**Post date:** [January 11, 2010, 3:55pm UTC](https://community.unix.com/t/touch-command/257318/6 "2010-01-11T15:55:02Z")

</div>

Hello,  
Im using solaris10, it does not create full path tlarkin:

```nohighlight
shell>echo "OOO" >> ./newdir/newfile.txt
bash: ./newdir/newfile.txt: No such file or directory

```

[/CODE]

However i know

```nohighlight
mkdir -p 

```

and its combinations will help as Scottn mentioned earlier.

---

<div class="post-metadata">

**Author:** ![tlarkin](https://community.unix.com/letter_avatar/tlarkin/32/6_22734026db12803ebb3e059622ac3534.png) [@tlarkin](https://community.unix.com/u/tlarkin)\
**Post date:** [January 11, 2010, 4:00pm UTC](https://community.unix.com/t/touch-command/257318/7 "2010-01-11T16:00:19Z")

</div>

Yeah I read your question wrong, sorry my bad. I thought the directory already existed.
