[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
*nix cut String
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 6
Thread images: 1
File: black-handled-scissors.jpg (35 KB, 1000x586) Image search: [Google]
black-handled-scissors.jpg
35 KB, 1000x586
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.
Thread replies: 6
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.