09-02-2011
Is it possible to grep a certain amount of characters?
I have a file similar to the following
filler filler filler
car 6 mazda
filler filler filler filler
car civic honda
car rav 4 toyota
filler filler
If i do a "grep -i car file.txt" the output would be
car 6 mazda
car civic honda
car rav 4 toyota
however, i want to have the first 9 characters of each line. I know that sort has a similar feature with +n, but I was wondering if i can do something similar to just get the following output:
car 6
car civic
car rav 4
I played with the cut command, the the field delimiter doesn't seem to work (since rav 4 contains a space).
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi All,
I have lines like below in a file
A /u/ab/test1.dat
A/u/ab/test2.dat
A /u/bb/test3.dat
A/u/cc/test4.dat
I will need
/u/ab/test1.dat
/u/ab/test2.dat
/u/bb/test3.dat
/u/cc/test4.dat
Pls help
Thanks (6 Replies)
Discussion started by: thumsup9
6 Replies
2. Shell Programming and Scripting
I need to sort a file, the sort is not a alphabetical sort, it's based on a predefined order which is read from a file called fSortOrder.
The format of the fSortOrder file is :
STARTPATH"
....
....
The file that needs to be sorted is called tmpUnsorted and contains data in the format : ... (6 Replies)
Discussion started by: Vashj
6 Replies
3. UNIX Desktop Questions & Answers
Hi there
I need to grep for a detail from a file. The pattern to search for involves escape sequences in it. This causes for the problem.
grep "P\_SOME\_STRING\_SEARCH" filename
Note, I have line like below in the file and expect it to grep.
select *
from my_system_param
... (3 Replies)
Discussion started by: guruparan18
3 Replies
4. UNIX for Dummies Questions & Answers
Hi folks
I am issuing the following command:
grep "" *
Looking for the characters \/:*?"<>|#+%& within all files in a directory, but the command fails being unhappy with pipe:
ksh: 0403-057 Syntax error: `|' is not expected.
How do I force the command to take the pipe | ? I guess... (2 Replies)
Discussion started by: daveaasmith
2 Replies
5. Shell Programming and Scripting
Hi all,
I'm trying to gather data directly following a keyword in a file but I have no guarantee where it will appear in said file so I can't use cut or anything else that assumes it will be located at a certain position. If anyone has any suggestions I'd be grateful. Here is an example of the... (7 Replies)
Discussion started by: Korn0474
7 Replies
6. Shell Programming and Scripting
Hi,
Is there a command to print one character x amont of times?
I need for example 10 comma's (,,,,,,,,,,). Instead of creating a loop, I was wondering if there is a way to do this with sed or awk?
Thanks! (3 Replies)
Discussion started by: Subbeh
3 Replies
7. Shell Programming and Scripting
Need Help For GREP
I have a file say g1.txt and content of file is below
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoDrives /t REG_DWORD /d 4 /f ,
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoClose /t REG_DWORD /d 1 /f ,... (4 Replies)
Discussion started by: jalpasoni
4 Replies
8. UNIX Desktop Questions & Answers
hey , i m trying to figure out how to do the following :
i got a text file the looks like so:
1031
1031
1031
1031
1031
1031
1031
1031
16500
16500
16500
16500
1031
1031 (4 Replies)
Discussion started by: boaz733
4 Replies
9. Shell Programming and Scripting
Hello folks i have file which is below, i want to extract last column of file that contains dm-21 or dm-13 or dm-N
it show output like
I have tried but i got this (16 Replies)
Discussion started by: learnbash
16 Replies
10. Shell Programming and Scripting
I am trying to understand what the grep command in ubuntu is trying to do here.
The contents of my test file is given below
harsha@harsha-H67MA-USB3-B3:~/Documents$ cat data
abcd
efghi
jklmno
pqr
stuv
wxyz
When I grep for 3 dots (...) without the parenthesis as follows I would expect the... (4 Replies)
Discussion started by: sreeharshasn
4 Replies
LEARN ABOUT MOJAVE
assetutil
assetutil(1) BSD General Commands Manual assetutil(1)
NAME
assetutil process asset catalog .car files
SYNOPSIS
assetutil [-ViotshMgpT] inputfile
DESCRIPTION
assetutil processes a .car file generated from a image catalog removing requested scale factors, device idioms, subtypes, performance and
memory classes. When thinning scale, idiom, subtype, performance, memory, and graphicsclassfallbacks can be given multiple times, the result-
ing file will contain all of the assets that match all of the parameters given. If scale, idiom, subtype and graphics class are given in one
set, the same parameters must all be present in the subsequent set of parmeters. (IE the count must match)
A list of flags and their descriptions:
-V version information for assetutil
-I Produce a JSON description of the asset catalog object with the given name to --output directory if given or to stdout if no output
path given. If no name is provided, report on the contents of the entire car file.
-i Keep all assets that have idiom that is given on the command line.
-s Keep all assets that have scale factor that is given on the command line, present scale factors will not be removed if there is no
fallback available.
-p Keep all assets that have the display gamut that is given on the command line, present display gamuts will not be removed if there
is no fall back avaliable.
-M Keep all assets that have memory class that is given on the command line, present memory class will not be removed if there is no
fallback available.
-g Keep all assets that have graphics class that is given on the command line. The present graphics class will not be removed if there
is no fallback available.
-h process the hosted idioms list, this is a list of the idioms that must always be preserved in the car file. This list cannot contain
universal, and the different idioms should be given in a comma separated list.
-i Idiom to keep. Can be one of universal/phone/pad.
-t Subtype to keep (integer)
-c Main Assets.car file used to supply the names of the assets to the -I (--info) and the dump options -d (--dump) and -D (--dump-
stack).
-o Output file name, if no output file is given then input file is overwritten.
-T compare thinning attributes 'scale=2:idiom=phone:memory=2:graphicsclass=MTL1,2/scale=2:idiom=phone:memory=1:graphicsclass=MTL2,2'
will print to stdout if the files was thinned with the above thinning attributes, would the same Asset file result in both cases.
Darwin Jan 3, 2018 Darwin