Author Topic: touch?  (Read 10142 times)

Rick Smith

  • Full Member
  • ***
  • Posts: 119
  • Karma: +4/-0
    • View Profile
touch?
« 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

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1323
  • Karma: +26/-0
    • View Profile
Re: touch?
« Reply #1 on: November 26, 2023, 11:35:08 pm »
Hi Rick,

Code: [Select]
[Y:\tmp]copy con: file2
test
^Z
        1 file(s) copied.

...gets you the following:

Quote
[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...

Tom

  • Full Member
  • ***
  • Posts: 196
  • Karma: +5/-0
    • View Profile
Re: touch?
« Reply #2 on: November 26, 2023, 11:41:08 pm »
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



Lars

  • Hero Member
  • *****
  • Posts: 1272
  • Karma: +65/-0
    • View Profile
Re: touch?
« Reply #3 on: November 26, 2023, 11:44:30 pm »
echo. >newfile.txt

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4804
  • Karma: +99/-1
    • View Profile
Re: touch?
« Reply #4 on: November 27, 2023, 12:09:27 am »
touch new.file creates a new file here and it's how I usually create one with file commander.
Code: [Select]
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


Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1323
  • Karma: +26/-0
    • View Profile
Re: touch?
« Reply #5 on: November 27, 2023, 12:27:54 am »
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...

Rick Smith

  • Full Member
  • ***
  • Posts: 119
  • Karma: +4/-0
    • View Profile
Re: touch?
« Reply #6 on: November 27, 2023, 03:10:49 am »
touch new.file creates a new file here and it's how I usually create one with file commander.
Code: [Select]
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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4804
  • Karma: +99/-1
    • View Profile
Re: touch?
« Reply #7 on: November 27, 2023, 04:15:13 am »
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.

Rick Smith

  • Full Member
  • ***
  • Posts: 119
  • Karma: +4/-0
    • View Profile
Re: touch?
« Reply #8 on: November 27, 2023, 07:34:18 am »
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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4804
  • Karma: +99/-1
    • View Profile
Re: touch?
« Reply #9 on: November 27, 2023, 07:47:15 am »
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.

Rick Smith

  • Full Member
  • ***
  • Posts: 119
  • Karma: +4/-0
    • View Profile
Re: touch?
« Reply #10 on: November 27, 2023, 03:03:30 pm »
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

Neil Waldhauer

  • Hero Member
  • *****
  • Posts: 1027
  • Karma: +24/-0
    • View Profile
    • Blonde Guy
Re: touch?
« Reply #11 on: November 27, 2023, 03:23:41 pm »
if you have touch, perhaps you also have which? What is the result of

Code: [Select]
which touch
?
Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4804
  • Karma: +99/-1
    • View Profile
Re: touch?
« Reply #12 on: November 27, 2023, 04:09:41 pm »
Try "yum reinstall coreutils" on the command line. Report the output.

Gregg Young

  • Jr. Member
  • **
  • Posts: 72
  • Karma: +0/-0
    • View Profile
Re: touch?
« Reply #13 on: November 27, 2023, 09:48:34 pm »
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

Alfredo Fernández Díaz

  • Jr. Member
  • **
  • Posts: 55
  • Karma: +0/-0
    • View Profile
Re: touch?
« Reply #14 on: November 28, 2023, 12:06:49 am »
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,