OS2 World Community Forum
OS/2, eCS & ArcaOS - Technical => Utilities => Topic started by: Rick Smith on November 26, 2023, 10:11:17 pm
-
Greetings,
I am wondering if I can (from CLI) create a file? In linux I would just say touch newfile, then I could nano and edit it. On Arca I use file commander but I do not see a way to create a file (I could have missed it), touch does exist Ive noticed in Arca but does not act in how I would expect. So basically I want to be able to create a new file in a directory using the CLI.
Regards,
Rick
-
Hi Rick,
[Y:\tmp]copy con: file2
test
^Z
1 file(s) copied.
...gets you the following:
[Y:\tmp]dir
The volume label in drive Y is RAMDISK.
The Volume Serial Number is 5777:6CCF.
Directory of Y:\tmp
11-26-23 5:32p 6 0 a--- file2
Is that what you are looking to do?
BTW: I haven't tried any other combos, as in: "copy con: filename" but w/o actual input...
-
So basically I want to be able to create a new file in a directory using the CLI.
Maybe I misunderstand you, but I would expect the following to work:
cd <directory>
e (or tedit or epm or whichever editor)
start typing
use Save as and give it a filename (some editors might even allow you to start the editor with a desired file name which will be created if it doesn't exist already)
Another possibility:
cd <directory>
copy con: <filename>
start typing
Ctrl+Z
-
echo. >newfile.txt
-
touch new.file creates a new file here and it's how I usually create one with file commander.
Directory of H:\tmp\test
11-26-23 3:06p <DIR> 0 ---- .
11-26-23 3:06p <DIR> 0 ---- ..
2 file(s) 0 bytes used
4,755,963 K bytes free
[H:\tmp\test]touch new.file
[H:\tmp\test]dir
Volume in drive H has no label.
The Volume Serial Number is 4558:45C3.
Directory of H:\tmp\test
11-26-23 3:07p <DIR> 0 ---- .
11-26-23 3:06p <DIR> 0 ---- ..
11-26-23 3:07p 0 124 a--- new.file
3 file(s) 0 bytes used
4,755,963 K bytes free
[H:\tmp\test]touch --version
touch (GNU coreutils) 8.31
-
Rick!
...In linux I would just say touch newfile, then I could nano and edit it...touch does exist Ive noticed in Arca but does not act in how I would expect...
Lars' trick is by far the quickest one I think!!! (kudos to you sir 8))
...ok, but having said that, what's the issue you're running into with 'touch'? I just tried it here, no problems...
-
touch new.file creates a new file here and it's how I usually create one with file commander.
Directory of H:\tmp\test
11-26-23 3:06p <DIR> 0 ---- .
11-26-23 3:06p <DIR> 0 ---- ..
2 file(s) 0 bytes used
4,755,963 K bytes free
[H:\tmp\test]touch new.file
[H:\tmp\test]dir
Volume in drive H has no label.
The Volume Serial Number is 4558:45C3.
Directory of H:\tmp\test
11-26-23 3:07p <DIR> 0 ---- .
11-26-23 3:06p <DIR> 0 ---- ..
11-26-23 3:07p 0 124 a--- new.file
3 file(s) 0 bytes used
4,755,963 K bytes free
[H:\tmp\test]touch --version
touch (GNU coreutils) 8.31
touch new.txt gets me
SYS0002: The system cannot find the file specified. "C:\temp\new.txt"
Regards
Rick
-
That's weird, what does touch --version report? Perhaps you have another touch in your PATH? That looks like the wrong error for a coreutils touch.
-
That's weird, what does touch --version report? Perhaps you have another touch in your PATH? That looks like the wrong error for a coreutils touch.
I get an error when I do touch --version.. Is this installed by default or do I have to install something with yum?
Rick
-
It's part of the coreutils package. I thought it was installed by default, but perhaps not. Possible you have a broken install of it, which can be fixed by reinstalling.
Look in your @unixroot\usr\bin directory to see if it there.
-
It's part of the coreutils package. I thought it was installed by default, but perhaps not. Possible you have a broken install of it, which can be fixed by reinstalling.
Look in your @unixroot\usr\bin directory to see if it there.
I tried through ANPM didnt seem to work. Is there a way to uninstall and start over?
Rick
-
if you have touch, perhaps you also have which? What is the result of
which touch
?
-
Try "yum reinstall coreutils" on the command line. Report the output.
-
Hi
You must be using 4OS2. It has an internal touch command which returns the error you reported. To use the touch.exe from the coreutils use the command touch.exe filename. If you are interested in having the touch command in 4os2 behave like touch.exe put in a feature request at http://trac.netlabs.org/4os2 and I will look at it. Thanks
Gregg
-
Hi,
[...] In linux I would just say touch newfile, then I could nano and edit it. On Arca I use file commander but I do not see a way to create a file (I could have missed it) [...]
I would guess FC does not have an obvious, explicit way to create new files because most of these will be application-specific, so there's basically no point in that. However, your saying "nano and edit it" suggests me that you are trying to create a plain text file, and FC has a built-in text editor indeed. The easiest way you can create such a new file with FC is using Shift+F4. This will prompt you for a filename; type the name of a non-existing file, and the editor will ask you if a new file with that name should be created. Answer Yes, optionally write some text, and exit the editor.
Hope this helps,
-
In linux I would just say touch newfile, then I could nano and edit it.
With OS/2 I would simlply say 'e filename' or on my systems where I'm used to med.exe 'med filename' or 'vs filename' or 'edit filename'. This opens the editor with the file filename even without the touch before. Guess nano would do the same without touch, does it?
You may see there are a lot of ways to do what you want. A simple 'dir >filename' creates a file too beside the other options already mentioned. But I know sometimes it's handy to have a touch.exe especially when porting software from nix. For that I often use OpenWatcoms wtouch.exe.