Search Results

Search: Posts Made By: doubleminus
2,868
Posted By doubleminus
Jim, Thanks for the reply. I did a poor job...
Jim,

Thanks for the reply. I did a poor job of describing what I was trying to do.

If a certain user is logged in...then I want to run a command. Otherwise, no command.
2,868
Posted By doubleminus
Simple BASH script not working?
So I need a script that does the following:

If a certain user is logged in

Run `command`

Else

Echo “incorrect user”


This is my first stab...which doesn't work:

#!/bin/bash
...
10,913
Posted By doubleminus
Nevermind. Got it. #!/usr/bin/perl print...
Nevermind. Got it.

#!/usr/bin/perl
print "Enter 10 characters\n";
chomp ($foo=<STDIN>);
@arr=split //, $foo;
for($i=0;$i<5;$i++) {
print $arr[$i+5] . " " . $arr[$i] . "\n";
}
10,913
Posted By doubleminus
So I dug around and found some code similar to...
So I dug around and found some code similar to what I want, but not quite (similar in that it can break a string down by characters).

#!/usr/bin/perl
print "Enter 10 characters\n";
chomp...
10,913
Posted By doubleminus
The string is actually going to be coming from...
The string is actually going to be coming from STDIN.
10,913
Posted By doubleminus
Perl, printing a string into columns
How can I use Perl to a take a string of 10 characters and print the last five characters of the string in columns 1-5 and the first five in columns 6-10?

Result:
0123456789

5 0
6 1
7 2
8 3...
59,462
Posted By doubleminus
Perfect, exactly what I needed. Great learning...
Perfect, exactly what I needed. Great learning experience. Thank you.
59,462
Posted By doubleminus
Perl - converting selected characters to upper/lower case
Using STDIN, how can I use perl to take an input string, with all lower case letters in the first five characters, and convert them to uppercase...

then take all uppercase letters in the second...
40,364
Posted By doubleminus
Thank you sir. I ended up with: awk...
Thank you sir. I ended up with:
awk '{gsub(/,/, "\t")gsub("\"","");print}NR==3{exit 0}' test

using your scripts as a basis for getting this figured out. Thank you so much.
40,364
Posted By doubleminus
Thank you Franklin, works perfectly. Some csv...
Thank you Franklin, works perfectly. Some csv files have quotes around the fields (e.g. "one","two","three","four") - how can I use awk to remove these upon printing as tsv?
40,364
Posted By doubleminus
Secondary question... any advice on how I...
Secondary question...

any advice on how I could specify which columns to print, upon converting a csv to a tsv? Like if I only wanted the first three columns of the tab-separated value to print?
40,364
Posted By doubleminus
Oh, okay - got it! sed "s/,/"$'\t'/g test ...
Oh, okay - got it!

sed "s/,/"$'\t'/g test

works like a charm!
40,364
Posted By doubleminus
Macintosh-2:$ sed --version sed: illegal option...
Macintosh-2:$ sed --version
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]


When...
40,364
Posted By doubleminus
Hmmm, I have the latest version of OS X Leopard...
Hmmm, I have the latest version of OS X Leopard and am using BASH...but I'm guessing that may have nothing to do with what sed version I'm running? (Sorry, quite new to this).
40,364
Posted By doubleminus
Thanks. When I do: sed 's/,/\t/g' test ...
Thanks.

When I do: sed 's/,/\t/g' test
it doesn't go to tabbed. It just eliminates spaces...?
40,364
Posted By doubleminus
Converting csv to tsv and back
Anyone have a simple UNIX script to look at for doing this? I'm interested in how to convert from csv to tsv, and then back again, if I want to.

Thanks!
5,306
Posted By doubleminus
Thanks guys!!
Thanks guys!!
5,306
Posted By doubleminus
Thank you - what should be in the file then?
Thank you - what should be in the file then?
5,306
Posted By doubleminus
Using sed to print a ruler
How can I use sed to print rulers of x characters in length on my terminal?

For example, I want sed to print a 50-character rule.

sed '/[1-50]/ p' ??

Thanks!
5,698
Posted By doubleminus
Yes, total is calculated above outside of the END...
Yes, total is calculated above outside of the END statement:
total = $3 + $4 + $5

($3-$5 being fields showing logins for each of three months)
5,698
Posted By doubleminus
How to sort alphabetically after finding values
I have a list of people in a usage log and need to print the names and phone numbers of people with over 500 logins. I'd also like to display these names alphabetically.

I have their total logins...
16,891
Posted By doubleminus
Perfect, thanks for the help guys! Works like a...
Perfect, thanks for the help guys! Works like a charm.
16,891
Posted By doubleminus
Multiple field separators in awk? (First a space, then a colon)
How do I deal with extracting a portion of a record when multiple field separators are involved.

Let's say I have:
Mike Harrington;(555) 555-5555:250:100:175
Christian Dobbins;(555)...
8,516
Posted By doubleminus
Using sed to extract Nth record?
I have a comma-separated record and I'd like to use sed to pull the Nth record from it.

It seems like it'd need to be something like this: sed -n 's/'"\,$1\,"'/&/p'

Am I close?
3,359
Posted By doubleminus
Great explanation. It's much more clear now. I...
Great explanation. It's much more clear now. I was just making things a bit too complicated. Thank you for the help.
Showing results 1 to 25 of 27

 
All times are GMT -4. The time now is 01:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy