Search Results

Search: Posts Made By: apmcd47
59,287
Posted By apmcd47
Try appending this to your command: 2>...
Try appending this to your command:


2> >(grep -v 'No such file or directory' >&2)
It should remove the above message from the STDERR but allow other messages to be printed.


Works for bash...
6,396
Posted By apmcd47
That is close - try this while read product id...
That is close - try this
while read product id features
do
printf "${product}, %s\n" ${features%#*}
done < Check_FileYour example was using only two variables (f1, f3) to read the fields...
9,024
Posted By apmcd47
How about one of these two lines: [ -f...
How about one of these two lines:
[ -f /var/chef/cache/cookbooks/bootstrap_cookbooks_version_* ] && echo /var/chef/cache/cookbooks/bootstrap_cookbooks_version_* | sed 's/.*version_//'...
Forum: Programming 11-11-2019
20,634
Posted By apmcd47
realloc() is not guaranteed to reallocate in...
realloc() is not guaranteed to reallocate in situ, which is why you do
str = realloc(str, mem); rather than realloc(str, mem); The next_read variable should be reset with something like next_read =...
7,135
Posted By apmcd47
I was going to say I agree with RudiC, but...
I was going to say I agree with RudiC, but realise $LINE should be a subset of $1, not the other way round, so Rudi's solution probably won't get the results you want. So let's look at what is wrong...
12,734
Posted By apmcd47
GNU Zip will decompress .Z files, sogunzip -c...
GNU Zip will decompress .Z files, sogunzip -c somefile.tar.Z | tar xf -orzcat somefile.tar.Z | tar xf -should work without having to install the compress utility. It may even be possible to use GNU...
3,315
Posted By apmcd47
Please give an example of what your output should...
Please give an example of what your output should look like. Because the file as listed has 0s and 1s on all lines, and therefore grep as you propose to use it will delete all lines,


Andrew
2,713
Posted By apmcd47
Assuming GNU tail you can either list lines from...
Assuming GNU tail you can either list lines from the end (--lines=1234) or from the beginning (--lines=+1234) of the file. Thus listing the full file could be done withtail --lines=+1 myfile
In your...
58,157
Posted By apmcd47
Did you find any examples on the web? This is the...
Did you find any examples on the web? This is the article I was alluding to in my previous post (https://stackoverflow.com/a/38862221). Also the output of the df command you are using needs to be...
58,157
Posted By apmcd47
In light of Neo's comments, I'll only give you...
In light of Neo's comments, I'll only give you some pointers.

First, install jq. It is a tool for creating, validating and editing JSON files and can be used to extract data from a JSON file,...
8,761
Posted By apmcd47
First, you need to quote your input: ./test.sh...
First, you need to quote your input:
./test.sh "[u/tmp/file.js, u/var/test.txt, u/tmp/llo.rft]"

Second, don't use the shell array construct - do this instead:
#!/bin/sh

FPATH="$1"

printf...
8,761
Posted By apmcd47
My original sed solution had a typo. This version...
My original sed solution had a typo. This version works for both the samples you gave, with and without the quotes:
#!/bin/sh

printf "Parameter 1: %s\n" "$1"
MYARRAY=`echo "$1" | sed 's/^\[//;...
3,730
Posted By apmcd47
So basically you are asking, "is my login shell...
So basically you are asking, "is my login shell bash or ksh?" And if there is no bash on your system it will be ksh, because that is the default, else you will have changed it by the time your...
10,379
Posted By apmcd47
I'm guessing which is an external command in your...
I'm guessing which is an external command in your environment. As such it doesn't take into consideration builtin commands (which is why it is much better to use type on bash, ksh and dash). The...
10,556
Posted By apmcd47
Further to Neo's and Don Cragun's comments, the...
Further to Neo's and Don Cragun's comments, the variables used in your example are shell-specific variables and therefore do not need to be exported.

Andrew
Forum: Programming 04-02-2019
2,676
Posted By apmcd47
Try this: (Python 2.7.12 on Ubuntu 16.04 Xenial) ...
Try this: (Python 2.7.12 on Ubuntu 16.04 Xenial)

ss = system_info['Ad_List']
searchObj = "primary"
resList = [f for f in ss if searchObj in f]

resList will be a list of one object, or...
Forum: Ubuntu 04-02-2019
15,569
Posted By apmcd47
According to one of the comments in the link you...
According to one of the comments in the link you posted, the correct directory for this on a Debian, and therefore Ubuntu system, is /lib/systemd/system-sleep, not /usr/lib/systemd/system-sleep.
...
Forum: Ubuntu 03-27-2019
12,736
Posted By apmcd47
My own tuppence worth on this: As this is...
My own tuppence worth on this:

As this is in the Ubuntu sub-forum, ps has a -b (size in bytes) option;
If you want the size of a file in bytes, surely the most accessible (and therefore most...
1,302
Posted By apmcd47
select appears to take note of the LINES and...
select appears to take note of the LINES and COLUMNS variables set on terminal resize. Try adding COLUMNS=0into your code prior to the select statement.

Andrew
1,988
Posted By apmcd47
Basically $h{$_}++returns the value of $h{$_}...
Basically $h{$_}++returns the value of $h{$_} then increments it. If there is no value at $h{$_} perl will initialise it to zero.

So, for each value that $_ may be, the first evaluation is zero...
1,668
Posted By apmcd47
bash: for f in *.tex.txt do mv ${f}...
bash:
for f in *.tex.txt
do mv ${f} ${f/.tex/}
done

More Posix compliant (I believe):
for f in *.tex.txt
do mv ${f} ${f%.tex*}.txt
done

Andrew
2,663
Posted By apmcd47
DonCragun's code as posted would have worked. You...
DonCragun's code as posted would have worked. You modified a crucial part of that code, vis
for file in server.log-$filename_time2*
This expands the wildcard; the if statement then checks the first...
5,614
Posted By apmcd47
My point was that you can do string manipulation...
My point was that you can do string manipulation per element, or for all elements in an array of strings, thus:$ array=( john paul george ringo )
$ echo ${array[0]/h/}
jon
$ for btl in...
3,796
Posted By apmcd47
Except that your shell will evaluate $PATH before...
Except that your shell will evaluate $PATH before executing sudo. Instead you would need to do the somewhat iffy looking sudo bash -c "eval echo \$PATH"or better still get use sudo -i and check your...
4,393
Posted By apmcd47
Please use the code tags for code, like it tells...
Please use the code tags for code, like it tells you in the message window. You either need to use the in-place option to sed, or use an intermediate file, like this
sed 's/^.*$/"&"/' ${OUTFILE}...
Showing results 1 to 25 of 134

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