Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: Nick1097
2,416
Posted By Scrutinizer
You need to source it: . "$(dirname...
You need to source it:
. "$(dirname "$0")/testfile"
1,630
Posted By methyl
Try to remember to not put space characters...
Try to remember to not put space characters around the equals sign in a Bourne Shell variable assignment.

Not the first time ......
1,630
Posted By jim mcnamara
Does you system have acl's ie., in ls -l...
Does you system have acl's ie.,
in ls -l output do you see

drwxrwxrwx+

some character after the perms?

What OS and shell are you using?
1,630
Posted By chakrapani
directory=`dirname /path1/path2/path3/file.txt` ...
directory=`dirname /path1/path2/path3/file.txt`
Change this line .. no spaces... Scripting does not like spaces
Likes to be close .. while with variable. :)
Forum: Programming 04-10-2012
1,832
Posted By itkamaraj
you can use substr function printf "%s\n",...
you can use substr function

printf "%s\n", substr $testline,0,50;
Forum: Programming 04-10-2012
1,832
Posted By yazu
print substr($testline, 0, 50), "\n"
print substr($testline, 0, 50), "\n"
Forum: Programming 04-10-2012
1,832
Posted By Skrynesaver
You could use a function like that below...
You could use a function like that below (UNTESTED CODE)

sub limit{
my ($string, $limit)=shift;
return length($string)>$limit ? substr($string, 0, $limit) : $string;
}
...
printf...
1,465
Posted By methyl
sed 'q' bigfile | grep "string" Nice post. Been...
sed 'q' bigfile | grep "string"
Nice post. Been looking for that one for a long time.

Any way of reading just the first line of a big file quickly is really useful. This has to be the shortest...
1,465
Posted By ctsgnb
Could be shorten: sed 'q' bigfile | grep...
Could be shorten:

sed 'q' bigfile | grep "string"

sed '/string/!d;q' bigfile
1,465
Posted By itkamaraj
awk '/pattern/ {print;exit}' input.txt
awk '/pattern/ {print;exit}' input.txt
1,465
Posted By CarloM
"doesn't work" is not exactly descriptive. You...
"doesn't work" is not exactly descriptive. You get an error message, blank output, or what?
1,465
Posted By methyl
head -1 filename | grep "string" However,...
head -1 filename | grep "string"

However, this is faster for large files:
sed -n '1,1p;1q' bigfile | grep "string"
1,535
Posted By Corona688
It prints out any lines containing the character...
It prints out any lines containing the character '/' -- nothing more, nothing less. It doesn't understand ls's output.
826
Posted By methyl
Yes. To get the value in kilobytes. du -k...
Yes.

To get the value in kilobytes.
du -k

Some versions have a "-h" (human-readable) format option.
1,535
Posted By zaxxon
The backslash escapes the slash and the $ stands...
The backslash escapes the slash and the $ stands for end of line in regular expressions.
1,518
Posted By CarloM
You could save a command/pipe by just passing the...
You could save a command/pipe by just passing the filename into awk for use as a pattern.
size=$(ls -RFs $dval | awk -vval=$name '$0 ~ val { print $1 }')
1,518
Posted By itkamaraj
i dont think, this command will give the correct...
i dont think, this command will give the correct size.

I Guess, it is giving the number of blocks. ( not the size )


size=$(ls -RFsh Documents | grep \/$ | grep Music | awk '{ print $1}')
1,518
Posted By CarloM
You need to strip off the units and convert to a...
You need to strip off the units and convert to a common unit before you try and add it to a total (you could have 3.6M, 4.0K, etc).
1,716
Posted By Corona688
You don't need the find utility to use a folder...
You don't need the find utility to use a folder which you already know of. All find is doing is printing out the relative path for you.

Just give du a full path or a relative path to where you...
Showing results 1 to 19 of 19

 

Featured Tech Videos

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