ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I want to remove the first line of a CSV using AWK.
I could do this in PHP but then what i'd have to do is read in the CSV, unset the first element of the array and fwrite the data back. but the CSV is HUGE and i don't want to take up all that memory.
so, how would i use awk to remove the first line of a CSV? i suppose we would remove characters till we come accross a CR or LF but how would i do that?
also, i'll have to run this as a cron. any guidance?
so then awk accesses filename.csv, reads all its contents to memory, ignores the first line and prints everything else to stdout?
i don't think this is what happens. the file is not read into memory. you can work on files that are larger than your available ram.
also, being able to replace the file by redirecting the stdout stream may depend on the shell, so i can't say this for all command lines. but if you try this in bash, you will get an empty file. when you redirect the stdout to a file, like '$ command > file.txt', the first thing the shell does is create the file 'file.txt'. so by the time gawk tries to read it, it is an empty file.
if you type the command '$ ls > newfile.txt', you will see the file 'newfile.txt' listed in itself.