Sup /g/, I'm trying to use cut to work with a text file, mostly because I'm retarded and just do not grasp regular expressions, at all. What I'm trying to do is output characters 10 to 20, of the first line only. I'm using...
cut somefile.txt -c 10-20
...and that is giving me characters 10-20 from every line.
What should I be doing differently here?
>>55322752
head -1 somefile.txt | cut -c 10-20
A little extra detail, though probably not relevant, I'm going to be cutting several sections of character X-Y, but only every from the first line of the file, and then echoing them to a different file later, so I'm really using something more like....
var1=$(cut somefile.txt -c 10-20)
var2=$(cut somefile.txt -c 35-40)
var3=$(cut somefile.txt -c 50-70)
var4=$(cut somefile.txt -c 75-80)
echo $var1
echo $var2
echo $var3
echo $var4
etc....
>>55322752
Or you could just tell me what regex you're tryng to create and I can help you
>>55322844
I'm not really sure how to describe what I'm doing in regex terms, I have a file that I'm going to be working with the first line only, and I need to take out characters A-B, C-D, E-F, etc (those would be numbers of that character in the line) and then output them later with some pipes between them, sometimes there will be one pipe, sometimes two, sometimes three.
>>55322844
>>55322876
Basically a have a non-delimited text file where fields are always in a certain character position that I need to turn into a pipe delimited file, with the fields in a different order than they are in in the original file, and the destination file having more fields than the original does which is why there are sometimes multiple pipes in a row.
Using cut and then echoes seemed "easy" for someone who is a regex retard, because I'd just grab what I need from line 1, output it the way I want, remove line 1 from original, and loop until the input file is zero length.