I have a file and would like to cut the first 100 characters of the first line. I tried it with the �cut�-command:
cut �c100- $file > $file.tmp
But this does not work, because it will cut the first 100 characters of each line. But I need to cut them only from the beginning of the file � so only from the first line.
When I will do it with the 'head'-command I would get this line cut of 100 characters. Thats for the line ok.
But my problem is that I have a file with a size of maybe 1GB. And it could be possible that the content is only 1 line. All what I want is to cut the first 100 characters of the file. This can I do with the command:
cut �c100- $file > $file.tmp
But I do not know if I have only 1 line in file. It could also have more lines in it. And then this command won't work anymore, because it will cut the first 100 characters of each line.
So, what should I do? Is there a command to do it for both situations? Or in minumum I would like to know how can I cut the first 100 characters of the first line of file if there are more lines?
thanks for you help - with these hints I could solve the problem.
@Scrutinizer: Thats exactly what I need. Strictly speaking I needed it for a file, but to redirect the output to a file is no problem:
sed '1s/.\{100\}//' file > file.tmp
@Girish19: With this statement I have the first 100 characters, but my problem was to have a file without these 100 characters. But nevertheless this is a very useful hint to extract the first 100 characters. I could use it at another position in my script.