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

*nix cut String

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 6
Thread images: 1

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


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.