Sponsored Content
Top Forums UNIX for Dummies Questions & Answers "cut" problem with leading spaces Post 302307473 by GKnight on Wednesday 15th of April 2009 12:55:22 PM
Old 04-15-2009
"cut" problem with leading spaces

I'm trying to use the cut command on the following output to remove the first 2 columns (this is output of "find -ls", if anyone wondering, which for some bizarre reason inserts leading spaces on AIX):

file.txt:

Code:
   16    4 -rw-r--r--  1 root      tech          3186 Apr 15 04:00 ./file1
 2140    0 -rw-r--r--  1 root      security         0 Apr 15 06:30 ./file2
 2141   18 -rw-r--r--  1 root      security     18126 Apr 15 09:00 ./file3
 1072    1 -rw-r--r--  1 root      tech           112 Apr 15 09:00 ./file4
  637   15 -rwxr-----  1 root      system       14515 Apr 15 12:08 ./file5
   18    2 -rwxr-x---  1 root      tech          1977 Apr 15 12:16 ./file6
 1140    1 -rw-r--r--  1 root      tech           128 Apr 15 09:00 ./file7
 1320    1 -rw-r--r--  1 root      tech            37 Apr 14 14:54 ./file8

output of "cat test.txt | cut -d ' ' -f 3-"

Code:
 16    4 -rw-r--r--  1 root      tech          3186 Apr 15 04:00 ./file1
   0 -rw-r--r--  1 root      security         0 Apr 15 06:30 ./file2
  18 -rw-r--r--  1 root      security     18126 Apr 15 09:00 ./file3
   1 -rw-r--r--  1 root      tech           112 Apr 15 09:00 ./file4
637   15 -rwxr-----  1 root      system       14515 Apr 15 12:08 ./file5
 18    2 -rwxr-x---  1 root      tech          1977 Apr 15 12:16 ./file6
   1 -rw-r--r--  1 root      tech           128 Apr 15 09:00 ./file7
   1 -rw-r--r--  1 root      tech            37 Apr 14 14:54 ./file8

Seems like the leading spaces are causing this problem. Is there a workaround to this as far as cut is concerned? Perhaps it's easier to just remove the leading spaces (not sure how to do it), any help will be appreciated.
 

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Unix "cut' and "awk" in Windows XP?

Hi, How can I execute Unix's ksh equivalent of "cut' and "awk" in Windows XP? For example, I want to execute ksh commands from Windows command prompt. Is there a place I can download "cut.exe" and "awk.exe" ? Thanks in advance (4 Replies)
Discussion started by: ihot
4 Replies

2. Shell Programming and Scripting

How to remove "New line characters" and "spaces" at a time

Dear friends, following is the output of a script from which I want to remove spaces and new-line characters. Example:- Line1 abcdefghijklmnopqrstuvwxyz Line2 mnopqrstuvwxyzabcdefghijkl Line3 opqrstuvwxyzabcdefdefg Here in above example, at every starting line there is a “tab” &... (4 Replies)
Discussion started by: anushree.a
4 Replies

3. UNIX and Linux Applications

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or question of my own) is: Oracle tns listener, "CT_LISTENER", and the enterprise manager (EM) of the instance, which is uniq instance and called... (0 Replies)
Discussion started by: talipk
0 Replies

4. UNIX for Advanced & Expert Users

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have a problem about the Oracle related components. I'm not able to find any answer yet, and waiting for your responses... Here is the configuration of my system: * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or... (1 Reply)
Discussion started by: talipk
1 Replies

5. Shell Programming and Scripting

How to cut a file using " ", but fields can be separated with more than one " "

Hello, let's say I have a text file: word11 word12 word13 word21 word22 word23 word31 word32 word33 and I want to put the second field of each line into a list: set list = `cut -d" " -f2 ${1}` and I use space (" ") as a delimiter, only that there's a catch: there can be more than... (12 Replies)
Discussion started by: shira
12 Replies

6. Shell Programming and Scripting

help for saving vertical datas to horizontal with "awk" or "cut"

hi, i have a file having datas like that ./a.txt 12344 12345 12346 12347 ..... ..... ... i want to save this datas to another file like that ./b.txt 12344 12345 12346 12347 ... ... ... i think awk can make this but how? :) waiting for ur help. (3 Replies)
Discussion started by: mercury
3 Replies

7. Shell Programming and Scripting

"read" command ignoring leading spaces

I have to read a file line by line, change it and then update the file. Problem is, when i read the file, "read" command ignores leading spaces. The file is a script which is indented in many places for clarity. How to i make "read" command read leading spaces as well. (3 Replies)
Discussion started by: vickylife
3 Replies

8. Shell Programming and Scripting

How to replace "®" "™" "with Spaces in UNIX

do U know how to replace the registered trademark "®" symbol or trade Mark "™" "with Spaces in UNIX (4 Replies)
Discussion started by: MMeari
4 Replies

9. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

10. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies
NBDST(8)						    BSD System Manager's Manual 						  NBDST(8)

NAME
nbdst -- NetBoot deferred shadow tool SYNOPSIS
nbdst [-recycle | -preallocate size] devnode shadowfile DESCRIPTION
nbdst is used during NetBoot to associate a shadow file with the disk image being used as the root device. After the shadow file is attached, subsequent writes to the root device will be redirected to the shadow file, which normally resides on local storage. nbdst is invoked by /etc/rc.netboot ARGUMENTS
The following arguments must be specified: devnode The device node of the root device, in the form "disk0" shadowfile Path to a shadow file which will be created and associated with the NetBoot root device OPTIONS
-recycle If a shadow file already exists, reset it and use it again. Otherwise, information written to an existing shadow file will reap- pear. Reusing a previous shadow file without resetting it requires that the shadow file be created with the same base image. -preallocate size Set the shadow file to the given size up front. This forces a reset of the shadow file (like -recycle). NOTE
nbdst can only be run as root. SEE ALSO
hdiutil(1), hdik(8) Mac OS X 29 Apr 2003 Mac OS X
All times are GMT -4. The time now is 05:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy