# Knife node edit NODE from file FILE?

**URL:** <https://discourse.chef.io/t/knife-node-edit-node-from-file-file/2735>\
**Category:** Chef Infra (archive)\
**Created:** [April 5, 2012, 5:28pm UTC](https://discourse.chef.io/t/knife-node-edit-node-from-file-file/2735 "2012-04-05T17:28:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christophe\_L](https://avatars.discourse-cdn.com/v4/letter/c/71c47a/32.png) [@Christophe\_L](https://discourse.chef.io/u/Christophe_L)\
**Post date:** [April 5, 2012, 5:28pm UTC](https://discourse.chef.io/t/knife-node-edit-node-from-file-file/2735/1 "2012-04-05T17:28:13Z")

</div>

Hello,

Is there a way to replace the “attributs” of an existing node in a  
non-interactive mode, using knife or another utility please ?

I can see in the documentation that there are the two following knife  
sub-commands:

- node edit NODE (options)  
Edit a node.
- node from file FILE (options)  
Create a node from a JSON file.

But my need is to ‘edit’ the _attributs_ of an existing node ‘from a file’, so  
a kind of merge of this two features 😉

Thanks in advance for your answers.

Best regards,  
Christophe

---

<div class="post-metadata">

**Author:** ![Joshua\_Timberman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joshua_timberman/32/424_2.png) [@Joshua\_Timberman](https://discourse.chef.io/u/Joshua_Timberman)\
**Post date:** [April 5, 2012, 11:31pm UTC](https://discourse.chef.io/t/knife-node-edit-node-from-file-file/2735/2 "2012-04-05T23:31:07Z")

</div>

Hello,

On Thu, Apr 5, 2012 at 11:28 AM, [cl.subscription@gmail.com](mailto:cl.subscription@gmail.com) wrote:

> Is there a way to replace the "attributs" of an existing node in a  
> non-interactive mode, using knife or another utility please ?
> 
> I can see in the documentation that there are the two following knife  
> sub-commands:
> 
> - node edit NODE (options)  
> Edit a node.
> - node from file FILE (options)  
> Create a node from a JSON file.
> 
> But my need is to 'edit' the _attributs_ of an existing node 'from a file', so  
> a kind of merge of this two features 😉

You can use knife node show with -Fj to dump a node to a JSON file.

```
knife node show mynode.example.com -Fj > nodes/mynode.example.com.json

```

Then edit the JSON file as you need and upload it to the server.

```
knife node from file nodes/mynode.example.com.json

```

You could also use a "knife exec" script to modify the node with the  
same DSL available to shef's main context.

[http://wiki.opscode.com/display/chef/Knife+Exec](http://wiki.opscode.com/display/chef/Knife+Exec)  
[http://wiki.opscode.com/display/chef/Shef](http://wiki.opscode.com/display/chef/Shef)

--  
Opscode, Inc  
Joshua Timberman, Technical Program Manager  
IRC, Skype, Twitter, Github: jtimberman
