Single line content file

OS - Ubuntu. I want to create file.txt in /home/z/Desktop , where the contents of the file are some text here .

The first and usual way starts nano /home/z/Desktop/file.txt and types some text here . after that press ctrl+x , press y and then Enter .

The second way: cat > /home/z/Desktop/file.txt , type some text here and press Enter and then ctrl+c

I hope I can run one line of the command to make it faster. I thought xdotool will work with cat (second method), but no, it does not work

+6
source share
1 answer

You can use "echo" in bash. eg:.

 echo "some text here" > file.txt 

If you do not need a new line character at the end of the file, use the -n argument:

 echo -n "some text here" > file.txt 
+10
source

Source: https://habr.com/ru/post/912998/


All Articles