I have a file and would like to cut the first 100 characters of the first line. I tried it with the ‘cut’-command:
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.
Do you have a solution for this?
Last edited by vbe; 09-03-2014 at 05:15 AM..
Reason: Do you mind stop using fancy fonts and colour, thanks
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:
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?
I could do it in this way
But it there maybe another way, because it would be better to do it with 1 statement...
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:
@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.
Hi Everyone,
i have a file 1.txt
<a><a"" dd>aaaaauweopriuew</f><">!(^)!</aa></ff>
<a><a"" dd>bbbbbuweopriuew</f><">!(^*)!</aa></ff>
i know i can use
perl -p -i -e "s/>aaaaa/aa/g" 1.txt
perl -p -i -e "s/>bbbbb/bb/g" 1.txt
to acheive only keep the first two characters of the five characters,... (4 Replies)
Hi,
I would like to cut last 13 characters of a file name and take the rename the file name as follows:
Input:
A.DAT20110517033732
Output:
A.DAT
I have tried the following command and cut last 13 characters.
echo A.DAT20110517033732 | awk '{print substr($0, length($0)-13)}'
... (3 Replies)
I need to cut the last seven characters of a variable length variable. The variable may be 7 characters or 70. I need to always be able to grab the last 7 characters. I looked at the cut command but it always seems to want to start at the beginning of a line, not the end and count backwards.
... (5 Replies)
Hi Gurus,
I am trying to execute the below command. However the output shows the value + path of the folder where the command is being executed. But I am only interested in the value but not the path.
du -hs /aps/inf/SeLogs
when I execute the above command, output is
32G... (5 Replies)
hello everybody
i am looking for a shell to cut a flat file (with a long unique line) according to a certain number of characters and redirect every result to an output file.
here is an example
MyFile :
12 3 456 12 3 456 12 3 456 .....
and i took every 9-characters including BLANKS... (6 Replies)
Guys,
can you help me in doing cut first 21 and 32-35 characters from file.
I tried with cut -c to cut first 21 characters ,It is succeeded.
But i need both first 21 and 32-35. (1 Reply)
Hi All,
Need to convert file names to upper case using tr command in Unix.
In a folder -> /apps/dd01/misc
there are two files like:
pi-abcd567sd.pdf
pi-efgh1.pdf
The output of should be like:
pi-ABCD567SD.pdf
pi-EFGH1.pdf
I have used the command to work as below:
for f... (3 Replies)
I know this sounds simple, but I have a logfile with
> something
> something_else
> another_entry
...
how do I cut the first 2 characters off the left side? I tried to use
cut -c 1-2 somefile > someotherfile
but that just cut gave me the 2 left characters, I want to cut those out... (2 Replies)
Hi Friends
I have a file
like
sample1.txt
------------
10998909.txt
10898990.txt
1898772222.txt
8980000000000.txt
I need to take first 3 characters of each line in a file and i need to print it '
like loop
109
108
189
898 (7 Replies)