talktome_prashanth
asked on
creating file in specified directory with one command
Hi,
Just by using one single step or command can we create a file in a specified directory?
The only command we have access is /bin/sh and is running as a root but (there is a sideway that /bin/bash can use scripts--note scripts NOT in separate file but scripts like typed after /bin/bash command )
eg:
#/bin/sh blah blah blah ------------------ this must create a specified file in a specified directory.
Thank You,
Prashanth
Just by using one single step or command can we create a file in a specified directory?
The only command we have access is /bin/sh and is running as a root but (there is a sideway that /bin/bash can use scripts--note scripts NOT in separate file but scripts like typed after /bin/bash command )
eg:
#/bin/sh blah blah blah ------------------ this must create a specified file in a specified directory.
Thank You,
Prashanth
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To create a file not using another commands You can use 'echo' of shell.
Example:
echo > /where/you/want/file
echo is not a utility. that's a shell command. and it doesn't need something else but /bin/sh
Example:
echo > /where/you/want/file
echo is not a utility. that's a shell command. and it doesn't need something else but /bin/sh
> echo > /where/you/want/file
being pedantic: this creates a non-empty file
you better use:
cp /dev/null /where/you/want/file
being pedantic: this creates a non-empty file
you better use:
cp /dev/null /where/you/want/file
:-))) LOL ahoffman
cp is an external command
that's at first.
nobody said about empty.
that's at second.
using echo is an exact solution.
that's at third.
cp is an external command
that's at first.
nobody said about empty.
that's at second.
using echo is an exact solution.
that's at third.
cat >/path-to/some-file <<EOF
First line
Second line
...
EOF
will place "First line", "Second line", etc in the file.