I just discovered, to my dismay, the following part of the cut man page:
-f, --fields=LIST
select only these fields; also print any line that contains no delimiter character, unless the -s option is specified
The -s option toggles the printing of lines with no delimiters.
In most cases, I would like lines with no delimiters to be considered as lines with a single field, so that:
would output a,
and
would output an empty line.
Is there an alternate version of cut where this is possible, or an option I don't know about?
As far as I understand, there is no option of cut that would return an empty line in the second case: if I use the -s option there is no line of output.
I can always use awk but in many cases this is not practical for me.
When cut encounters consecutive delimiters it seems to count each instance as a field, at least with spaces. Is this typical behavior for any delimiter?
#:~$ ifconfig eth0 | grep HWaddr
eth0 Link encap:Ethernet HWaddr 94:de:80:a7:6d:e1
#:~$ ifconfig eth0 | grep HWaddr | cut -d " " -f... (6 Replies)
I'm having bother getting both lines contained in a file to output as the same value.
A simple example:
john:123456:123:456:doe
john:123456:123:doe
cut -d: -f1,4 input file
john:456
john:doe ^ first line should be same as second.
trick one for me, i know why it's because of the... (4 Replies)
not sure how to do it. wan't to delete it using cut and grep ince i would use it in the shell.
but how must the command be?
grep "64.233.181.103 wwwGoogle.com" /etc/hosts | cut -d
the delimeter is just a space. can you help meplease. :D (1 Reply)
I have a file like name file.txt whose contents are 3 fields separated by colon':' . somewhat like
code/OR_R1400_RC4/BM_ATEMP_11.0.1.33:28/01/2010:N
code/OR_R1400_RC5/BM_ATEMP_11.0.1.35:28/01/2010:Y
code/OR_R1400_RC4/BM_ATEMP_11.0.1.33:29/01/2010:N... (8 Replies)
Hi guys,
I need to analyze the following alert log file:
Beginning log switch checkpoint up to RBA , SCN: 3916025539605
Sat May 1 00:54:52 2010
Thread 1 advanced to log sequence 271423 (LGWR switch)
Current log# 1 seq# 271423 mem# 0: /dw/stg_redo01/log_dwstg_g1_m1.log
Current log# 1... (7 Replies)
i need to cut the string in a textfile but each line has a specific way of cutting it (different lengths)
i have a for loop that gets the string line per line, then each line has to be compared:
for x in `cat tmp2.txt`; do
if; then
echo 'BAC'
elif
... (6 Replies)
Hi,
I need to find the number of tab delimiters in the first line of a file.So using
word=`head -1 files.txt`
I have extracted the first line of file into a variable word.It has 20 tab delimted columns.So can anyone help me in finding the number of delimiters?
I am using csh and I am a... (5 Replies)
Hi
I wanted to cut the feilds comming after % and After $ at one go
can we do some thing like this cut -f 2 -d "%|$" (But it doesnot work)
Input File
BWPG %TCPRP1 $SCSPR000
BWPH %TCPRP1 $SCSPR003
BWPI %TRTYUP ResourceDescription="IMPRIMANTE " $BWOPTY
BWPJ %ZOMBIE ... (4 Replies)