Search Results

Search: Posts Made By: FUTURE_EINSTEIN
22,992
Posted By zaxxon
No secret. If you count the number and the...
No secret. If you count the number and the arguments that are following, separated by a comma, you see that the 1st part containing the numbers is defining the layout, and the 2nd part is just...
22,992
Posted By zaxxon
$ awk...
$ awk 'BEGIN{printf("%-3s%-8s%-6s%-5s%-20s\n","#","name","gend","age","occup")}{printf("%-3s%-8s%-6s%-5s%-20s\n",NR,$1,$2,$3,$4)}' infile
# name gend age occup
1 Jane F 39 manager...
1,689
Posted By RudiC
Looks like you are not making friends with your...
Looks like you are not making friends with your csh problems/questions. Neither could I answer, as my csh days are gone for long.

In bash, however, I would phrase your command like so:
if [...
3,238
Posted By aashish.sharma8
lines=(`grep '404' $1 | cut -d" " -f5`) ...
lines=(`grep '404' $1 | cut -d" " -f5`)

Remove the brackets.
3,238
Posted By bakunin
Sigh.... Please, STOP USING C-shell while...
Sigh....

Please, STOP USING C-shell while you still can!

C-shell (csh) is considered outdated, very buggy, unreliable and generally to be avoided. Read this in-depth article...
1,814
Posted By RudiC
I was mislead by the OP using bytes+=temp into...
I was mislead by the OP using bytes+=temp into thinking he/she wanted to sum up several lines' byte counts. If there is only one line expected, use Don Cragun's one line shell version.
1,814
Posted By bakunin
In fact there is: use the "system()" function in...
In fact there is: use the "system()" function in awk. But to be honest RudiC provided a much better solution if he got your intention right and you should first try to avoid the system()-call.
...
1,814
Posted By Don Cragun
If you're trying to get the output RudiC...
If you're trying to get the output RudiC suggested, you don't need awk. You can just do:
printf "Number of bytes: %d\n" $(grep datafeed.php | cut -d" " -f8) < an411
in the shell. You already had...
1,814
Posted By RudiC
I don't know what the construct $(temp...) is...
I don't know what the construct $(temp...) is doing in your awk program - first, it is a shell variable that is assigned, second, the grep command does not know on what input it should work. If I...
1,814
Posted By Don Cragun
temp=$(grep "datafeed\.php" | cut -d" " -f8) is...
temp=$(grep "datafeed\.php" | cut -d" " -f8)
is a shell command; not a gawk command.
1,188
Posted By Corona688
[] is a range of characters to match. You...
[] is a range of characters to match.

You are telling it to match any line which contains the characters d, a, t, a, f, e, e, d, ., p, h, p.

So, any line which contains p will match.

Any...
1,537
Posted By Skrynesaver
Either temp=`grep "[datafeed.php]" $5 | cut...
Either

temp=`grep "[datafeed.php]" $5 | cut -f8 -d' '`
or
temp=$(grep "[datafeed.php]" $5 | cut -f8 -d' ')
would assign the value of the 8th field in the matching line, provided there was...
9,922
Posted By xbin
#This is an array in csh set files = (`ls`) ...
#This is an array in csh
set files = (`ls`)

#The number of elements in the array files
echo $#files

#element 4 in the array files
echo $files[4]

#elements 1 though 3 of the array files...
9,922
Posted By RudiC
One option - which I don't know if it works in...
One option - which I don't know if it works in csh - would be to assign the whole stuff to an array and then access array [position]:
ar=($(echo $files))
echo ${ar[17]}
You have to verify this in...
3,682
Posted By Don Cragun
Directories aren't text files and the filenames...
Directories aren't text files and the filenames stored in directories won't usually appear to be at the start of a line. Try:
ls ~|grep -c '^K'
1,205
Posted By Scott
Hi. Use back-quotes. i.e. ...
Hi.

Use back-quotes.

i.e.

[Scotts-MBP:~] scott% echo $0
csh
[Scotts-MBP:~] scott% set X=`date '+%y'`
[Scotts-MBP:~] scott% echo $X
12
[Scotts-MBP:~] scott%
2,421
Posted By alister
Show us the entire script. That behavior would...
Show us the entire script. That behavior would only occur if the argument to ls is quoted or if pathname expansion is disabled (very unlikely).



It has nothing to do with ^. It has to do with...
2,421
Posted By alister
That pattern is incorrect. If the second...
That pattern is incorrect. If the second character is any non-digit (or even if there is no second character at all), the pattern will match. * allows zero digits to match.

Regards,
Alister
2,421
Posted By vgersh99
ls ?[0-9]* | awk '{print substr($0,2,1), $0}'...
ls ?[0-9]* | awk '{print substr($0,2,1), $0}' OFS='\t' | cut -f2-
2,421
Posted By Corona688
ls /tmp/?[0-9]* | sort -r
ls /tmp/?[0-9]* | sort -r
1,358
Posted By guruprasadpr
Hi The closing brackets were placed at the...
Hi

The closing brackets were placed at the wrong places:


echo "Type in a positive number"
read X
I=2
while [ $X>$I ]
do
if [ $(($X%$I)) == 0 ]
then
echo "It is not prime"...
953
Posted By agama
The s is a substitute command. It will match the...
The s is a substitute command. It will match the pattern between the first and second slant characters, and replace it with what is between the second and third slant characters. That is very...
1,860
Posted By shamrock
echo "Desktop/Myfiles/pet/dog/puppy" | awk...
echo "Desktop/Myfiles/pet/dog/puppy" | awk -F"dog" '{print split($1,a,"/")-1}'
1,860
Posted By itkamaraj
echo "Desktop/Myfiles/pet/dog/puppy" | awk -F\/...
echo "Desktop/Myfiles/pet/dog/puppy" | awk -F\/ '{for(i=1;i<=NF;i++){if($i~/dog/)print i-1}}'
1,250
Posted By Corona688
Don't forget the obvious: ( cd...
Don't forget the obvious:

( cd ~/MyFolder/Files/PersonalFiles/databases/
ls food/tomato
ls items/cup )
Showing results 1 to 25 of 28

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