How to clean all contents of a file from Terminal on Mac? I've been searching for this about a day (I don't want to delete the file)
Assuming it's a file with text content, there are many ways to do it.
You can do either > filename.ext or cat /dev/null > filename.ext
You just need to write an empty content to a file, eg:
> your.file
Related
I have an app that has a config file. Is there a way to replace all the text in the file with other text i have. Instead of using sed to modify the current file. Id like to just rip all the text from the file and add in my own file then save the changes, Ideally this will be run with the user signed in as the user or sudo as well so permissions should be ok.
file location: ~/Library/Application \Support/App/config_file.json
How about this?
cat < other_file > my-config.json
I want to copy the content of file in Multiple files have the same extension how to do that using linux command
I try Run the commond :
cat t1.txt > /etc/apache2/site-available/*le-ssl.conf
and
echo "hello" > /etc/apache2/site-available/*le-ssl.conf
but Give me an error result " Ambiguous redirect"
Any ideas?
A redirect will not duplicate a data stream. If you want multiple copies, use tee. For example:
< t1.txt tee /etc/apa.../*le-ssl.conf
I need empty .txt files and wanted to know if there is any possibility to do it in the terminal on a mac?
the empty txt files should be named by numbers from 1 to 200, like 1.txt,2.txt,3.txt...200.txt
thanks in advance
run on terminal
for i in {1..200}; do echo > ${i}.txt; done
macOS How to read Pages/Numbers file in command line ?
I have userd 'cat'
cat /Users/administrator/Downloads/test.pages
but get:
????(??#?-QEQEQEQEQEQEQEQE?kYe??Ȍ?"8?,?9A?i;??1]?????=.SE[????Sqs-?,?iY??3]]QEQEQEQEQEQEQEQE??????(??(??(??(??(??(??(??(??(??(??????(??(??(??(??
addtional
I can use cat to watch .md file
Pages/Numbers files are .zip archives of binary files, not text files. In order to read them on the command line, you'll need a special tool, though I don't believe one exists at the moment
I have a text file fold.txt that contains one line fold_nam:
$ cat fold.txt
fold_nam
This name in the the text file is an output that was created during a program run of a folder's name that now contains other files that I need to work with.
I am writing a big script and now I need to enter this folder and I need to get the name from the text file. I tried several things but cannot really work it out.
There's no need to use cat:
cd $(<fold.txt)
If you want to read the line into a variable: read -r folder_name < fold.txt
You should be able to do this:
cd $(cat fold.txt)
or
cd `cat fold.txt`