Hello,
i want to use new line character in cut command
i want to display 3rd line of a file using cut only( not by sed or head -tail command)
can anyone suggest me ?
Regards
Hello,
i want to use new line character in cut command
i want to display 3rd line of a file using cut only( not by sed or head -tail command)
can anyone suggest me ?
Regards
Try...
cut -d '
' -f 3 file1
I am not sure but I think this should also work.
cut -d"\r" -f3 file
Hello,
I tried this command in all three shells TCSH BASH and KSH
it doesnot work
cat file
this is 1st line
this is 2nd
this is 3rd line
this is 4th line
%ingrx025:/home/grvobad2/shell/tes/deepak/shell >echo $SHELL
/bin/tcsh
%ingrx025:/home/grvobad2/shell/tes/deepak/shell >cut -d"\r" -f3 file
cut: invalid delimiter
%ingrx025:/home/grvobad2/shell/tes/deepak/shell >cut -d "\r" -f3 file
cut: invalid delimiter
%ingrx025:/home/grvobad2/shell/tes/deepak/shell >bash
bash-3.00$ cut -d"\r" -f3 file
cut: invalid delimiter
bash-3.00$ ksh
$ cut -d"\r" -f3 file
cut: invalid delimiter
---------- Post updated at 01:47 AM ---------- Previous update was at 01:43 AM ----------
Even i tried this
cut -d '\
? ' -f 3 file
this is 1st line
this is 2nd
this is 3rd line
this is 4th line
%ingrx025:/home/grvobad2/shell/tes/deepak/shell >bash
bash-3.00$ cut -d '
> ' -f 3 file
this is 1st line
this is 2nd
this is 3rd line
this is 4th line
bash-3.00$ ksh
$ cut -d '
> ' -f 3 file
this is 1st line
this is 2nd
this is 3rd line
this is 4th line
$
Try:
cut -d$ -f3 file
cut -d$ -f3 file it doesnot work too:(
xargs -d"|" < inputFile | cut -d"|" -f3
none of the options are giving desired result
My Post#7 should work. In that I m just merging all lines by |(pipe) delimiter and than printing 3rd column.
$ cat input
line1
line2
line3
line4
line5
$ xargs -d"|" < input
line1|line2|line3|line4|line5
$ xargs -d"|" < input | cut -d"|" -f3
line3
To get further idea on your problem, please post sample input data and desired output data.
This does the job:
sed -n 3p inputfile
Is there another reason you want to stick with cut?
Robin,
Liverpool/Blackburn
UK
As I am sure you know already, this whole exercise with "cut" is a complete waste of time.
$ cat input
line1
line2
line3
line4
line5
$ cut -d'
' -f 3 input
line3
Exactly, Ygor's suggestion seems to be working well.
bash/ksh93:
$ cut -d$'\n' -f3 infile
this is 3rd line
Perhaps there is something fishy with the OP's input file?