Reading complete line after spaces


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading complete line after spaces
# 8  
Old 12-14-2009
@franklin52

Thanks for the explanation. However for someone learning scripting in general. Where would that information be published? I checked the man pages on OSX and RHEL for "cut". I do not see that type of information?

Regards,

Abacus




SORRY:
MAN CUT
Numbers or number ranges may be followed by a dash, which selects all fields or columns from the last number to the end of the line.

Last edited by abacus; 12-14-2009 at 11:04 AM.. Reason: USED MAN PAGE
# 9  
Old 12-14-2009
Quote:
Originally Posted by abacus
@rcdwayx,


I have checked man cut and have not located what you have done with the trailing dash after f2. Could you please elaborate on this? Or point me to the doc that contains this type of switch.

Code:
$ echo "My Name is Ashish" |cut -d" " -f2-


Regards,

Abacus
Code:
       Use one, and only one of -b, -c or -f.  Each LIST is made up of one range, or many ranges separated  by  com-
       mas.   Selected  input is written in the same order that it is read, and is written exactly once.  Each range
       is one of:

       N      N'th byte, character or field, counted from 1

       N-     from N'th byte, character or field, to end of line

       N-M    from N'th to M'th (included) byte, character or field

       -M     from first to M'th (included) byte, character or field

       With no FILE, or when FILE is -, read standard input.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with reading directory paths with spaces from a file

Hi I want to know how to handle the spaces in the below scenario. I have a file (CON_zip_path_1.txt) which has some directory paths with spaces in directory names . My requirement is to unzip these zip files to another path. Please see the code below and the error. CON_zip_path_1.txt... (4 Replies)
Discussion started by: paul1234
4 Replies

2. UNIX for Dummies Questions & Answers

Reading filenames with spaces

Hello I've got a certain no. of files in a directory whose names I'm reading and redirecting into a temporary text file using the command below: ls -l | grep ^- | awk '{print $9}'However, whenever the file names contain spaces the above command considers only the part of the file name up to... (5 Replies)
Discussion started by: S. BASU
5 Replies

3. Shell Programming and Scripting

Reading in data that has spaces in it.

I have a csv file called template.csv which has the following data Name, Age, Height Jessica Jesse, 18, 150 Now what I want to do is use a shell script to read the name age and height which looks like this: #!bin/sh INPUT='template.csv while read Name Age Height do echo... (2 Replies)
Discussion started by: JSNY
2 Replies

4. Shell Programming and Scripting

How to avoid the truncating of multiple spaces into a single space while reading a line from a file?

consider the small piece of code while read line do echo $line done < example content of example file sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the output is like sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the... (4 Replies)
Discussion started by: Kesavan
4 Replies

5. Shell Programming and Scripting

reading in arguments with spaces

I want to be able to read in input which contain spaces and put that into an array. Each field should be delimeted by a space and should be a different array element. However I cant get it to work. any tips? read input //type field1 field2 field3 echo "$input" array="$input" Thanks in... (11 Replies)
Discussion started by: Calypso
11 Replies

6. Shell Programming and Scripting

Split a line on positions before reading complete line

Hi, I want to split before reading the complete line as the line is very big and its throwing out of memory. can you suggest. when i say #cat $inputFile | while read eachLine and use the eachLine to split its throwing out of memory as the line size is more than 10000000 characters. Can you... (1 Reply)
Discussion started by: vijaykrc
1 Replies

7. UNIX for Dummies Questions & Answers

how to append spaces(say 10 spaces) at the end of each line based on the length of th

Hi, I have a problem where I need to append few spaces(say 10 spaces) for each line in a file whose length is say(100 chars) and others leave as it is. I tried to find the length of each line and then if the length is say 100 chars then tried to write those lines into another file and use a sed... (17 Replies)
Discussion started by: prathima
17 Replies

8. Shell Programming and Scripting

Reading a file using sh with spaces in filename

Hi I am trouble parsing through a file with spaces in the filename. I need to grab "supportIDPS/SCM/windows_install/file groups/dds.fgl" and then do a md5sum on it. I am using sh. Any help is appreciated. Here is an example of the input file: 7eedbc9f7902bf4c1878d9e571addf9a ... (4 Replies)
Discussion started by: jekl5
4 Replies

9. UNIX for Dummies Questions & Answers

Reading a line including spaces

Hi All, I have a script that reads a file and echo it back to std out. Test.txt 1aaaaaaaaaaa . The script is ReadLine.sh #!/bin/ksh cat $1 | while read file do echo $file done I invoke the script as ReadLine.sh Test.txt The output that I get is (1 Reply)
Discussion started by: aksarben
1 Replies

10. Shell Programming and Scripting

prob with spaces in reading a file

i have a file in unix having data like cat dog (having spaces in the beginning) when i read it in a shell script cat file_name |while read line do echo $line done it will print cat dog spaces at the beginning are removed.... i dont want these spaces to be... (2 Replies)
Discussion started by: Amardeep
2 Replies
Login or Register to Ask a Question