how can I get file content backwards [duplicate] - unix

This question already has answers here:
How can I reverse the order of lines in a file?
(24 answers)
Closed 7 years ago.
I need to print a file, but from the last line to the first.
I think I can append a number to the beginning of each line, sort descending, and then remove the line numbers, but there's probably some more elegant way to do that. is there?

You can use tac command
(tac- cat spelled backwards...)

Related

What does "?" mean in Erlang? [duplicate]

This question already has answers here:
Erlang: What does question mark syntax mean?
(3 answers)
Closed 2 years ago.
I see alot of code in erlang with a question mark before it, what does it mean? Is it Macros or can it be used in another way? Example:
{Total, Pids} = run(10, 20),
?assertEqual(200, Total),
?assert(processes_stopped(Pids)).
or:
?MODULE
When you try call macros, you need add in start of name ‘?’. Notes: the macros can create with or without arguments.

R - Weird behavior of grepl [duplicate]

This question already has an answer here:
grepl not searching correctly in R
(1 answer)
Closed 6 years ago.
I want to know if there is a certain string contained in another string. This works fine here:
grepl("a","a")
However, what I actually want to test is the following and this one doesn't work:
grepl("is.na(x)","is.na(x)")
Can anyone help?
You can escape the special characters like this:
grepl("is\\.na\\(x\\)","is.na(x)")
[1] TRUE

creating string of numbers seperated by commas [duplicate]

This question already has answers here:
Creating a comma separated vector
(6 answers)
Closed 6 years ago.
I am trying to create a comma separated string exactly like this to put in a url: 1,2,3,4,5 but when I try: paste0(1:5,sep=",") it returns: [1] "1," "2," "3," "4," "5," The spaces are causing issues. How do I get rid of them?
This is not the same question as: this SO post the solution is almost the same, but the question approaches it from a different angle. My question is trying to suppress the spaces, the linked question wants them.
Try to use collapse="," instead of sep=",":
paste0(1:5,collapse=",")
[1] "1,2,3,4,5"

How to grep records which has a full stop in R [duplicate]

This question already has answers here:
grepl for a period "." in R?
(2 answers)
Closed 6 years ago.
I am trying to grep all the records of a dataframe which has a full stop in it. But it returns all the records in the dataframe no matter it has a full stop or not.
dot=e[grep(".", e$e1),]
View(dot)
Can anyone help me to do this in the correct way please?
You can either use the fixed=True argument, or use "\."
dot=e[grep(".", e$e1, fixed=T),]
or
dot=e[grep("\\.", e$e1),]
The first option is probably preferable.

R displays numbers in scientific notation [duplicate]

This question already has answers here:
How can I paste 100000 without it being shortened to 1e+05? [duplicate]
(3 answers)
Closed 9 years ago.
The result of function was displayed in scientific notation, I want to change it back to normal, but only for that function, I don't want to change the global setting. Can anyone help?
You can do:
format(functionResult, scientific=FALSE);
or:
as.integer(functionResult);

Resources