Hi I have two questions that I have been struggling with for quiet some time. I would be very grateful if someone can please help me.
Merging of files - I have 3 files that I want to write to one single file so I give the command:
Cat file1, file2, file3 >> file4
Is copying the data fine but the problem is it doesn't start the next file from a new line, it starts the first line of a different file from the end of the previous file. So I want it to print the data from the next file from the new line instead of continuing to write from the last line of previous file. Is it possible?
I have another question:
Regarding variables - I read online on my forums and followed the steps to set some variables that should load when I start the command prompt but it's not. What I am doing is:
I put some variables in the bash profile and exported them also, but when call them in the command prompt they don't show up. Ex:
I mentioned in the profile for
var1=10
Export var1
Then I went to the command prompt and typed:
Echo $ var1.
Doesn't show anything
Please if someone can help me with these two. I am on Linux.
The command given Cat file1, file2, file3 >> file4 will fail for two reasons:
Cat: command not found
cat file1, file2, file3
cat: file1,: No such file or directory
cat: file2,: No such file or directory
The phenomenon that you describe is due to a non-standard *nix text file, which NEEDS a terminating newline char which is obviously missing in your files. You can combine the files as desired but with additional efforts.
The Export and Echo commands won't work for the same reason as Cat above - leading upper case. Question is why there are no error messages.
Lower case should work:
echo $ var1.
$ var1.
If you want the variable expanded, remove the space after the $ sign.
Please show EXACTLY what you typed, char by char, case sensitive, no spaces or other chars (period?) added nor removed, when you assigned and expanded a variable, or used a command, or whatsoever, and what the system put out as a result.