facing problem with cut command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers facing problem with cut command
# 1  
Old 05-25-2005
facing problem with cut command

hi ,
i used ls -ltr | cut -f 1 > \dev\tty

but all teh coulmns r getting printed instead of only one........how can i resolve this?


prob 2 :
wud be able start cutting from last field......supposing in the case of dyanmic list.i dunno the field number of last column.......so is here anyway to cut a word that is at end?



Thanks and Regards
# 2  
Old 05-25-2005
awk

how about

ls -lrt | awk '{print $9}'


im assuming this is what you are wanting to do ??
# 3  
Old 05-25-2005
Quote:
Originally Posted by vivekshankar
hi ,
i used ls -ltr | cut -f 1 > \dev\tty

but all teh coulmns r getting printed instead of only one........how can i resolve this?
ls -ltr | cut -f1 -d ' '
Quote:
Originally Posted by vivekshankar
prob 2 :
wud be able start cutting from last field......supposing in the case of dyanmic list.i dunno the field number of last column.......so is here anyway to cut a word that is at end?
nawk '{print $NF}' list.i

Quote:
Originally Posted by vivekshankar


Thanks and Regards
# 4  
Old 05-25-2005
Thank you guys!! :-)

I will check...was struggling to get the last field......i guess i have learn awk , till now i dun have any idea abt awk...so b4 goin along with this code i guess it wud be better for me to learn basics of awk :-)

Thanks!!!

Regards
Vivek.S
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

I'm facing problem with rpm command, when running the command and appears this error:

exec(): 0509-036 Cannot load program /usr/opt/freeware/bin/rpm because of the following errors: 0509-022 Cannot load module /opt/freeware/lib/libintl.a(libintl.so.1). 0509-150 Dependent module /opt/freeware/lib/libiconv.a(shr4.o) could not be loaded. 0509-152 Member... (4 Replies)
Discussion started by: Ohmkar
4 Replies

2. Shell Programming and Scripting

Problem in using cut command

Hi Friend , i have one file say xyz.lst and it has content like dn: cn=m.hariharan,cn=employee,cn=delhi circle,cn=users,dc=industowers,dc=c dn: cn=ajay.jain,cn=employee,cn=gujarat circle,cn=users,dc=industowers,dc=com dn: cn=ajitkumar.thakor,cn=employee,cn=gujarat... (4 Replies)
Discussion started by: harish anand
4 Replies

3. Shell Programming and Scripting

Problem facing command using shell

Dear Brothers! Need your help for the case where I am running one command on prompt and its giving us the correct output, but when i use the same command from shell its directs no output.:wall: the command on command prompt is ls -ltrh * | nawk '{if ($5~ '/$'M'/') print $9}' | grep -v... (1 Reply)
Discussion started by: jojo123
1 Replies

4. Shell Programming and Scripting

Problem with cut command

Hi! I get a md5 hash of a file with this command: openssl md5 /Users/me/MyLogo.png | cut -f 2 -d ' ' "cut" because I just want the hash. But there is a problem -> that doen't work with a path with spaces: openssl md5 /Users/me/MyLogo 2.png | cut -f 2 -d ' ' The result is "2.png)=" ...... (1 Reply)
Discussion started by: Dirk Einecke
1 Replies

5. Shell Programming and Scripting

CUT command problem

Hi I have a strange problem when using cut command when i am using the below command, it is working fine,I am getting the data in new file xyz.dat cut -c 1-75 abc.dat > xyz.dat when i am using the below command, I am getting the data in new file abc.dat , but empty file cut -c 1-75... (4 Replies)
Discussion started by: vaas
4 Replies

6. Shell Programming and Scripting

Problem facing in using awk command

Hi., I am not able to replace the string with another string using gsub fn of awk command. My code: awk 'BEGIN gsub(004,IND,004)' p.txt and my i/p file p.txt is of the format: av|004|adkf|Kent,004|s av|005|ssdf|Kd,IT park|s . . . and my desired o/p should be of : (13 Replies)
Discussion started by: av_vinay
13 Replies

7. Shell Programming and Scripting

Problem using cut command in shell script

I'm new to shell programming, and am having a problem in a (Korn) shell program, which boils down to this: The program reads a record from an input file and then uses a series of "cut" commands to break the record into parts and assign the parts to variables. There are no delimiters in the... (2 Replies)
Discussion started by: joroca
2 Replies

8. Shell Programming and Scripting

Problem with cut command

I am trying to take one part of my text from file and save it to variable $x I tryed this... x=`cut -c 6-9 $fajl` my file looks like this fajl: 21890001277 89386911 23638FBCDC 28EE01A1 0000 26855 124 244326 21890001277 89766911 23638FBCDC 28E021A1 0000 26557 134 684326 21890001277... (7 Replies)
Discussion started by: amon
7 Replies

9. Shell Programming and Scripting

Problem with UNIX cut command

#!/usr/bin/bash cat /etc/passwd | while read A do USER=`echo “$A” | cut -f 1 -d “:”` echo “Found $USER” done This shell script should make USER = the first field of the first line of the file /etc/passwd Eg: adm daemon bob jane kev etc ... However USER=echo... (3 Replies)
Discussion started by: kevin80
3 Replies

10. UNIX for Dummies Questions & Answers

Cut command problem !

Hi all! Here is my problem : $ more file yougli:passwd:123456:3265:Yepa Yepo:/home/yougli:/bin/ksh As you can see, in the field "information", there are two spaces between "Yepa" and "yepo". My problem is : $ PARAM='more file | cut -d":" -f5' $ echo $PARAM Yepa Yepo Now i only... (2 Replies)
Discussion started by: tomapam
2 Replies
Login or Register to Ask a Question