Search Results

Search: Posts Made By: Unbeliever
76,593
Posted By Unbeliever
you could do it something like this. Firs...
you could do it something like this.

Firs create a script called, say mygrep, and put in it:


#!/bin/sh
grep -nf test.txt "$1" | sed -e "s!^!$1:!"


The you can do this:


find . -type...
16,472
Posted By Unbeliever
You could first try file filename.trz ...
You could first try


file filename.trz


This should tell you if its any commonly recognised compression format. If it simply is a unusually named gzipped (or compressed) tar file then the...
12,837
Posted By Unbeliever
The tar command you are using tars the file...
The tar command you are using tars the file 'output' onto your tape.

You need something like:


tar cvf /dev/rmt/0 -I ouput
3,795
Posted By Unbeliever
What you are doing here is assigning the...
What you are doing here is assigning the 'standard output' of running '"scale=2;22/10" | bc' to the variable 'test'. Unfortunately that is not a valid command and the only output is to standard...
43,559
Posted By Unbeliever
Only the owner of a file or root may change the...
Only the owner of a file or root may change the permissions on a file no matter what its current permissions maybe.

Root may delete any file. But for any other id there are restrictions as...
3,795
Posted By Unbeliever
When using expr the '/' operation is not divide...
When using expr the '/' operation is not divide but returns the quotient. You need to use bc or something similar, for example:

echo "scale=2;22/10" | bc
14,449
Posted By Unbeliever
I'm not 100% sure of what the question. The find...
I'm not 100% sure of what the question. The find answers above count the number of regular files in a particular folder which doesnt appear to be the question.

I *think* this code will give you...
5,130
Posted By Unbeliever
Oops :eek: :o Should of been: egrep...
Oops :eek: :o

Should of been:


egrep '^[A-Za-z]{2}[0-9]{4}:' /etc/passwd | awk -F':' '{print $1}'

or

egrep '^[A-Za-z]{2}[0-9]{4}:' /etc/passwd | sed -e 's/:.*//'
5,130
Posted By Unbeliever
more passwd | awk -F ":" '{print $1}' | egrep...
more passwd | awk -F ":" '{print $1}' | egrep '[A-Za-z]{2}[0-9]{4}'


Is slightly more compact but gives you exactly the same thing. Since the user id is the first field in the password file you...
5,130
Posted By Unbeliever
more passwd | awk -F ":" '{print $1}' | grep...
more passwd | awk -F ":" '{print $1}' | grep '[A-Za-z][A-Za-z][0-9][0-9][0-9][0-9]'
6,907
Posted By Unbeliever
In the /etc/shadow file you have the encrypted...
In the /etc/shadow file you have the encrypted passwords for each user. There are several fields separated by ':' characters. The 1st field is the username the 2nd is the 13 character one way has of...
2,766
Posted By Unbeliever
#!/bin/sh DATA=$1 FILE=$2 sed -e "1i...
#!/bin/sh

DATA=$1
FILE=$2

sed -e "1i $DATA" $FILE > $FILE.new


The file ending .new should have the correct data in it.
2,293
Posted By Unbeliever
Undeniable though it is that the pipe and...
Undeniable though it is that the pipe and redirect operators are taught as shell basics, I feel it is unlikely that someone with understanding of those basics would of asked the question in the first...
2,293
Posted By Unbeliever
It is only useless if it has or serves no...
It is only useless if it has or serves no purpose.

In the past I've found that with new shell users it is easier to explain commands piped together rather than explain redirection. Therefore the...
1,306
Posted By Unbeliever
Check the manual for the date command. Really...
Check the manual for the date command. Really depends on the format the date is inputed. the '%w' variable for date formating returns the 'day of the week' where 0 is sunday and 6 is Saturday.

In...
2,293
Posted By Unbeliever
Any of these will work cat myfile.txt | tr...
Any of these will work

cat myfile.txt | tr -d 0-9
sed -e 's/[0-9]//g' file.txt
perl -p -e 's/[0-9]//g' file.txt
5,170
Posted By Unbeliever
Check the manual for your shell for the 'read'...
Check the manual for your shell for the 'read' command. If you need to turn off echoing of characters when the user puts in the password it can be turned off and on using the 'stty' command.
9,672
Posted By Unbeliever
/etc/profile and .profile (or indeed...
/etc/profile and .profile (or indeed .bash_profile) are run when bash is called by the login process, This happens when you log on via a terminal or telnet or ssh or something similar.

.bashrc...
4,137
Posted By Unbeliever
I good way of checking text files for unusual...
I good way of checking text files for unusual characters is to use 'cat -vet'. The following command will print any non ascii characters (look for the '^' symbol) as something visible, mark the end...
8,112
Posted By Unbeliever
Strictly speaking, I think what is being assigned...
Strictly speaking, I think what is being assigned is a reference to an array, the elements of which are the keys and values of the hash %tag (which are the string 'info' and the value of the variable...
21,034
Posted By Unbeliever
Looks like you have a mix of csh and sh style...
Looks like you have a mix of csh and sh style syntax. For sh it would be


exam="AAA BBB CCC"
for ii in $exam
do
if [ "$ii" = "AAA" ]
then
echo "PASS"
else
echo...
9,916
Posted By Unbeliever
I think the main problem is that your original...
I think the main problem is that your original question was not put very well.

You seemd to ask how you can read a file and output it with a space at the begining of each line. This is a rather...
5,725
Posted By Unbeliever
Assuming your data is in a file 'data.txt', this...
Assuming your data is in a file 'data.txt', this perl will do it


$name = $ARGV[0];
$count=0;
$biggest=0;

open (DATA,"<data.txt");

while($line = <DATA>)
{
chomp;
if ($line =~...
6,210
Posted By Unbeliever
If order is an issue while(<>) { ...
If order is an issue

while(<>)
{
chomp;
@a= split(/,/);
push (@order,$a[0]) if (!$sum{$a[0]});
$sum{$a[0]} += $a[1];
}

foreach $key (@order)
{
print "$key,$sum{$key}\n";
}
6,210
Posted By Unbeliever
If output order is not a problem this simple perl...
If output order is not a problem this simple perl script will do:


while(<>)
{
chomp;
@a= split(/,/);
$sum{$a[0]} += $a[1];
}

foreach $key (keys %sum)
{
print...
Showing results 1 to 25 of 182

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