Hi I have a file named Data cat Data 513074691077 i want to sum all these lines, can we use any direct command for that in unix.
Active1 year, 7 months ago
I'm a little new to Shell Scripting and I want to create a new file inside the script and want to add content and then close it. It should not take the arguments from the user. Everything from the path and content is predefined. How can I do it?
Gowtham Gopalakrishnan
35433 gold badges55 silver badges2323 bronze badges
2 Answers
Just use output redirection. E.g.
The
> will write all stdin provided by the stdout of echo to the file outputfile here.
Alternatively, you could also use
tee and a pipe for this. E.g.
Immanuel velikovsky oedipus and akhnaton pdf. Immanuel Velikovsky's fourth book on Egyptian history. Oedipus and Akhnaton (1960) is Velikovsky’s fourth book, and second in the series following Ages in Chaos.Velikovsky explains that he: “ read Freud’s last book, Moses and Monotheism, and was prompted to read more about Akhnaton, the real hero of that book.
Be aware that any of the examples will overwrite an existing
outputfile .
If you need to append to a currently existing file, use
>> instead of > or tee -a .
If you don't accept user input in this line, no user input can change the behaviour here.
gertvdijkgertvdijk
53k1818 gold badges149149 silver badges245245 bronze badges
I think it is superior to use a here doc to create a new file in a script. It is cleaner looking, which I believe encourages readability.
Fate unlimited codes psp iso. For example:
The Aaron HallAaron Hall
'-' in <<- is optional, allowing for tabbed indents which will be stripped when the file is created. The quotes around the 'EOF' prevent the 'here doc' from doing any substitutions.
70411 gold badge88 silver badges2222 bronze badges
Not the answer you're looking for? Browse other questions tagged bash or ask your own question.
Last Activity: 10 April 2001, 4:35 PM EDT
Append Text To File Linux
Thanks Given: 0
Hi, once again -
Ok here it is: a).I used the touch command to create a file (touch directory.list) b).I then added this line: - date '+The date is %a %h %d, %Y %nIt is %I:%M %p' > directory.list -So that this date function would go at the top of my script c).Now I want to display a detailed listing(including i-node numbers) of the contents of my dir and append the output to this file(directory.list) Now I've tried this for a few days and the closet I've came is: ls -i > directory.list But when I do this it erases the date function. There has got to be an easier way. I need help Thank you again, I don't why it's overwriting - maybe something to do with the permissions. b Unix Append To File
Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |